new Turtle(x, y, heading)
A Turtle that can be controlled in the style of the LOGO Language
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
x |
number | 0 | Initial X Position of Turtle |
y |
number | 0 | Initial Y Position of Turtle |
heading |
number | Initial Heading of Turtle |
Methods
backward(steps)
Move the turtle backwards without painting
Parameters:
| Name | Type | Description |
|---|---|---|
steps |
number | the number of steps to move |
color(c)
Sets the color of the pen
Parameters:
| Name | Type | Description |
|---|---|---|
c |
Color | a P5js valid color |
drawLSystem(ls, step, angle)
Draws an L-System based on default values.
The turtle knows how to draw certain types of LSystems
F means forward with pen down
f means fordward with pen up
X or any other letter pass.
[ push
] pop
+ turn right
- turn left
F means forward with pen down
f means fordward with pen up
X or any other letter pass.
[ push
] pop
+ turn right
- turn left
Parameters:
| Name | Type | Description |
|---|---|---|
ls |
LSystem | the LSystem to draw |
step |
number | the size of the step |
angle |
number | the angle of turns |
drawString(string, step, angle)
Draw a string (used by drawLSystem)
Parameters:
| Name | Type | Description |
|---|---|---|
string |
string | |
step |
number | |
angle |
number |
forward(steps)
Move the turtle forward
Parameters:
| Name | Type | Description |
|---|---|---|
steps |
number | the number of steps to move forward |
hd(heading)
Set heading of turtle East=0, CW
Parameters:
| Name | Type | Description |
|---|---|---|
heading |
number | the heading of the turtle |
hide()
Hides the Turtle
left(rot)
Rotate the turtle to its left by certain degrees
Parameters:
| Name | Type | Description |
|---|---|---|
rot |
number | angle to rotate in degrees |
pen_down()
Put the pen down so it writes
pen_up()
Put the pen up so it doesn't write
pop()
Reverts to previous saved state of the turtle removing it from the stack
pos(x, y)
Set turtle position in coordinate system
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | the X position |
y |
number | the Y position |
push()
Pushes the current state of turtle to stack.
right(rot)
Rotate the turtle to its right by certain degrees
Parameters:
| Name | Type | Description |
|---|---|---|
rot |
number | angle to rotate in degrees |
show()
Shows the Turtle
style(weight)
Set the weight of the pen
Parameters:
| Name | Type | Description |
|---|---|---|
weight |
number | the weight of the pen |