def move(t, length): """Move Turtle (t) forward (length) units without leaving a trail. Leaves the pen down. """ pu(t) fd(t, length) pd(t)
def draw_pie(t, n, r): """Draws a pie, then moves into position to the right. t: Turtle n: number of segments r: length of the radial spokes """ polypie(t, n, r) pu(t) fd(t, r*2 + 10) pd(t)
rt(t, angle) fd(t, r) lt(t, 90+angle) fd(t, 2*y) lt(t, 90+angle) fd(t, r) lt(t, 180-angle) # create the world and bob world = TurtleWorld() bob = Turtle() bob.delay = 0.01 pu(bob) bk(bob, 130) pd(bob) # 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) die(bob) # dump the contents of the campus to the file canvas.eps #world.canvas.dump() wait_for_user()
def skip(t, n): """lift the pen and move""" pu(t) fd(t, n) pd(t)