forward(pixels_moved)
backward(pixels_moved)
circle(radius)
circle(radius, degrees)
circle(radius, degrees, points)
left(degrees)
right(degrees)
begin_fill()
end_fill()
bgcolor(col)
color(col)
penup()
pendown()
pensize()
speed(s)
setx(x)
sety(y)
setposition(x, y)
To move Tracy in the direction she is currently facing, use the forward() command, or backward() to move her in the opposite direction. It will move her the specified number of pixels.
forward(pixels_moved)
backward(pixels_moved)
Examples:
forward(10) moves Tracy forward 10 pixels
backward(20) moves Tracy backward 20 pixels
forward(-30) moves Tracy backward 30 pixels
backward(-15) moves Tracy backward 15 pixels
The Tracy grid is 400 pixels by 400 pixels. The x and y axes both go from -200 to 200. You may set Tracy's x-value with setx(), y-value with sety() or set both with setposition().
setx(x)
sety(y)
setposition(x, y)
Example:
setposition(40, 70) - move Tracy to (40, 70)
setx(-50) - move Tracy to (-50, 70)
sety(30) - move Tracy to (-50, 30)
To rotate Tracy clockwise (CW), use the right() command. Use left() for counterclockwise (CCW). It will rotate her the specified number of degrees.
Note, this rotates Tracy, but doesn't move her to a new position on the grid!
Geometry review:
90° - quarter turn (right angle)
180° - half turn (face opposite direction)
270° - 3/4 turn
360° - full turn
left(degrees)
right(degrees)
Examples:
left(90) - 1/4 turn CCW
left(180) or right(180) - turn around
right(90) - 1/4 turn CW
The circle() command can be used to draw circles and regular polygons. Tracy starts drawing the circle at the "bottom", not the middle.
circle(radius) draws a full circle
circle(radius, degrees) draws a sector
circle(radius, degrees, points) draws a regular polygon
Examples:
circle(7) - draws a circle of radius 7
circle(14, 180) - draws a semicircle of radius
circle(20, 360, 5) - draws a regular pentagon of radius 20
Note 1: You will usually want to use 360° to draw a full polygon.
Note 2: You will often want to draw polygons in other ways.
All of Tracy's movements (forward, backward, circle, setposition, setx, sety) will be shown with a "pen" as long as the pen is down. If you don't want this, use penup() then pendown() you wish to start showing the movements again. You can also change the size of the pen with pensize().
Note: By default, the pen is down and the pen size is 1 pixel wide.
pensize(pixels)
penup()
pendown()
Example:
pensize(4) - makes the pen 4 pixels thick
forward(10) - draws a line 10 pixels wide
penup()
forward(10) - moves forward 10 without drawing
pendown()
forward(10) - draws a line 10 pixels wide
If there's an enclosed area you want to fill, use the command begin_fill(), have Tracy create a closed area, then use the end_fill() command to fill the area with the chosen color.
begin_fill()
end_fill()
Example:
begin_fill()
circle(5)
forward(10)
circle(5)
end_fill() - fills the 2 circles
To change the color of the pen/fill, use the color() command. You can also change the background color with bgcolor(). Make sure the color names are in quotes because they are Strings.
Note: Default background color is white, and default pen/fill color is black.
bgcolor(col)
color(col)
Examples:
bgcolor("pink")
forward(10) - draws a black line
begin_fill()
color("blue")
circle(7) - draws a blue circle (on the outside, not the inside)
color("green")
end_fill() - fills the circle green
The speed() command changes the speed. 1 is slowest, larger numbers are faster. 0 is no animation (instant).
speed(s)
Example:
speed(5)
speed(10)
speed(0)