Turtle graphics ( see http://en.wikipedia.org/wiki/Turtle_graphics) is
a graphics package for creating vector graphics. It has been widely
used for teaching purposes as well as to create artistic designs and
works.
There are three things we need to know about a turtle:
forward(n) |
moves the turtle forward - n steps |
left(n) |
turns the turtle left by n degrees |
right(n) |
turns the turtle right by n degrees |
pu() or penup() |
pen up (so the turtle won't
write) |
pd() or pendown() |
pen down (so the turtle will
write) |
color(c) |
sets the current color example: color("red") |
begin_fill() ... end_fill() |
fills a shape with the current color |
ht() |
hides the turtle (usually done as the second-to-last line)
|
st() or showturtle() |
show the turtle |
circle(size) | creates a circle of radius "size" example: circle(20) |
circle(size, extent) | creates a part of a circle of radius "size" and of
angle "extent" (starting at the current angle) example: circle(20, 180) creates half a circle |
speed("fastest") | put this at the beginning of your program to speed things up! |
write(text, parameters) | write text at turtle position. example: write("that's all folks!", align="center", font=("Courier", 18, "bold")) |
done() |
when the program is done; this should be the last line of your program. |
Further information: