Class: Turtle

Turtle(x, y, heading)

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
Source:

Methods

backward(steps)

Move the turtle backwards without painting
Parameters:
Name Type Description
steps number the number of steps to move
Source:

color(c)

Sets the color of the pen
Parameters:
Name Type Description
c Color a P5js valid color
Source:

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
Parameters:
Name Type Description
ls LSystem the LSystem to draw
step number the size of the step
angle number the angle of turns
Source:

drawString(string, step, angle)

Draw a string (used by drawLSystem)
Parameters:
Name Type Description
string string
step number
angle number
Source:

forward(steps)

Move the turtle forward
Parameters:
Name Type Description
steps number the number of steps to move forward
Source:

hd(heading)

Set heading of turtle East=0, CW
Parameters:
Name Type Description
heading number the heading of the turtle
Source:

hide()

Hides the Turtle
Source:

left(rot)

Rotate the turtle to its left by certain degrees
Parameters:
Name Type Description
rot number angle to rotate in degrees
Source:

pen_down()

Put the pen down so it writes
Source:

pen_up()

Put the pen up so it doesn't write
Source:

pop()

Reverts to previous saved state of the turtle removing it from the stack
Source:

pos(x, y)

Set turtle position in coordinate system
Parameters:
Name Type Description
x number the X position
y number the Y position
Source:

push()

Pushes the current state of turtle to stack.
Source:
Rotate the turtle to its right by certain degrees
Parameters:
Name Type Description
rot number angle to rotate in degrees
Source:

show()

Shows the Turtle
Source:

style(weight)

Set the weight of the pen
Parameters:
Name Type Description
weight number the weight of the pen
Source: