Turtle Graphics - Basic Motion
[Index] [<< Previous section: The Graphics Canvas] [Next section: Curved Paths >>]
forward exprfd expr- Description: moves the turtle forward expr pixels, in the direction it is facing.
- Examples:
fd 100fd -50.25
Note that you can use negative values to go backwards. - Examples:
back exprbk expr- Description: moves the turtle backward expr pixels, exactly opposite to the direction that it's facing.
- Examples:
bk 80bk -35.75
Note that you can use negative values to go forward. - Examples:
left exprlt expr- Description: rotates the turtle expr degrees counterclockwise.
- Examples:
lt 90.30lt -45
Note that you can use negative values to rotate clockwise. - Examples:
right exprrt expr- Description: rotates the turtle expr degrees clockwise.
- Examples:
rt 120rt -60
Note that you can use negative values to rotate counterclockwise. - Examples:
setpos [ expr expr ]- Description: moves the turtle to the specified location without drawing. The input is a list of two numbers, the X and Y coordinates.
- Example:
setpos [100 100] - Example:
setxy expr expr- Description: moves the turtle to the specified location without drawing. The two inputs are numbers, the X and Y coordinates.
- Example:
setxy 100 100 - Example:
setx expr- Description: moves the turtle horizontally from its old position to a new horizontal coordinate. expr is the new X coordinate.
- Example:
setx 150 - Example:
sety expr- Description: moves the turtle vertically from its old position to a new vertical coordinate. expr is the new Y coordinate.
- Example:
sety -220 - Example:
setheading exprseth expr- Description: turns the turtle to a new heading. expr is a number, the heading in degrees clockwise from the positive Y axis.
- Example:
seth 120 - Example:
home- Description: moves the turtle to the initial position (canvas center), pointing upwards.
- Example:
home - Example:
[Index] [<< Previous section: The Graphics Canvas] [Next section: Curved Paths >>]