#sudo pip install swampy from swampy.TurtleWorld import * world = TurtleWorld() world.ca_width=800 world.ca_height=800 bob = Turtle() def draw(t,length,n): if n == 0 : return angle = 50 fd(t, length*n) lt(t,angle) draw(t, length, n-1) rt(t, 2*angle) draw(t, length, n-1) lt(t, angle) bk(t, length*n) # draw(bob,4,20) # print("finished painting") # wait_for_user() def drawFigure(n): for i in range(n): fd(bob,50)
circle() calls polygon() calls polyline() arc() calls polyline() """ from swampy.TurtleWorld import * import math world = TurtleWorld() bob = Turtle() jay = Turtle() bob.delay = 0.01 jay.delay = 0.01 world.ca_width = 700 world.ca_height = 700 world.canvas = world.ca(world.ca_width, world.ca_height, bg='white') def drawSquare(d, t, length): '''Draw square with edge length 'length'. Turtle instance, edge length ===> square d: turn direction (either 'rt' or 'lt') t: Turtle object length: edge length ''' for i in range(4): fd(t, length) d(t)