import turtle import math koch_size=400 koch_step=int(turtle.numinput('Koch Smowflack','How many levels would you like to draw the curve of snowflake?')) turtle.bgcolor('black') turtle.color('sky blue', 'white') turtle.hideturtle() def koch_line(length, step): if step > 0: length = length/3 for angle in [60, -120, 60, 0]: koch_line(length, step-1) turtle.left(angle) else: turtle.forward(length) turtle.penup() turtle.backward(koch_size/math.sqrt(3)) turtle.left(30) turtle.pendown() turtle.tracer(100) turtle.begin_fill() for i in range(3): koch_line(koch_size, koch_step) turtle.left(-120) turtle.end_fill() turtle.update() turtle.done()
Comments
7 responses to “2019.06.13(am): How to draw fractal with python turtle”
-
Hello there! This is kind of off topic but I need some
help from an established blog. Is it difficult to set up your own blog?
I’m not very techincal but I can figure things out pretty quick.
I’m thinking about setting up my own but I’m not sure where to begin. Do you have any ideas or
suggestions? Appreciate it -
I’m pretty pleased to find this website. I wanted to thank you for your time just
for this wonderful read!! I definitely liked every part
of it and i also have you saved to fav to look at new things on your website. -
Thanks for ones marvelous posting! I actually enjoyed reading it, you are a great author.I will
be sure to bookmark your blog and will often come
back at some point. I want to encourage one to continue your great posts, have a nice weekend! -
These are really enormous ideas in concerning blogging. You have touched some good things here.
Any way keep up wrinting. -
Thanks for your personal marvelous posting! I definitely enjoyed reading it, you are a great author.
I will be sure to bookmark your blog and will eventually come back very soon. I want to encourage one to
continue your great work, have a nice evening!-
Thanks. I try and try to update as often as pissible
-
-
Hi there, just wanted to say, I liked this article.
It was inspiring. Keep on posting!
Leave a Reply
You must be logged in to post a comment.