def circle(t, r): """Draws a circle with the given radius. t: Turtle r: radius """ arc(t, r, 360) # bob._delay(0.01) bob.penup() radius = 250 square(bob, radius) bob.rt(90) bob.fd(150) bob.rt(90) bob.fd(30) bob.rt(180) bob.pendown() bob._delay(0.01) circle(bob, radius) bob.penup() # bob._delay(30) # polygon(bob, 7, 250) screen = Screen() screen.exitonclick() # bob = Turtle() # print(bob) # a = input("press")
def koch(t, n): """Draws a koch curve with length n.""" if n<3: t.fd(n) return m = n/3.0 koch(t, m) t.lt(60) koch(t, m) t.rt(120) koch(t, m) t.lt(60) koch(t, m) def snowflake(t, n): """Draws a snowflake (a triangle with a Koch curve for each side).""" for i in range(3): koch(t, n) t.rt(120) bob = Turtle(shape="turtle") bob._delay(0.0001) bob.x = -150 bob.y = 90 snowflake(bob, 300) screen = Screen() screen.exitonclick()
angle: peak angle in degrees """ y = r * math.sin(angle * math.pi / 180) t.rt(angle) t.fd(r) t.lt(90 + angle) t.fd(2 * y) t.lt(90 + angle) t.fd(r) t.lt(180 - angle) # create the world and bob bob = Turtle(shape='turtle') bob._delay(50) bob.pu() bob.bk(130) bob.pd() # draw polypies with various number of sides size = 40 draw_pie(bob, 5, size) draw_pie(bob, 6, size) draw_pie(bob, 7, size) draw_pie(bob, 8, size) screen = Screen() screen.exitonclick() # dump the contents of the campus to the file canvas.eps