It’s over midnight here.. Since the source code in one of my videos is not very readable, I decided to publish the Python source code of the video in this blog post.
import turtle def draw_curve(): window = turtle.Screen() turt=turtle.Turtle() turt.setpos(-300,-100) turt.clear() turt.speed('fastest') turt.hideturtle() vonKoch(turt,5,500) turt.left(120) vonKoch(turt,5,500) turt.left(120) vonKoch(turt,5,500) turt.left(120) vonKoch(turt,5,500) window.exitonclick() def vonKoch(turt,depth,length): if depth == 0: turt.forward(length) else: vonKoch(turt,depth-1,length/3) turt.right(60) vonKoch(turt,depth-1,length/3) turt.left(120) vonKoch(turt,depth-1,length/3) turt.right(60) vonKoch(turt,depth-1,length/3) draw_curve()
That’s it for now. Time to go to sleep.
Advertisements