Turtle

Turtle

new Turtle(x, y, heading)

A Turtle that can be controlled in the style of the LOGO Language
Source:
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
Source:
Parameters:
Name Type Description
steps number the number of steps to move

color(c)

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

down()

Put the pen down so it writes
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
Source:
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)
Source:
Parameters:
Name Type Description
string string
step number
angle number

forward(steps)

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

hd(heading)

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

left(rot)

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

pop()

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

pos(x, y)

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

push()

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

show()

Shows the Turtle
Source:

style(weight)

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

up()

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