public class Turtle
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
int |
currentPenState |
float |
currentTheta |
float |
currentX |
float |
currentY |
static java.lang.String |
VERSION |
Constructor and Description |
---|
Turtle(processing.core.PApplet theParent)
Basic constructor, creates a Turtle in the middle of the screen.
|
Turtle(Turtle T)
Copy constructor, creates a copy of the input Turtle.
|
Modifier and Type | Method and Description |
---|---|
void |
back(float distance)
Move Turtle backward.
|
void |
clearTurtleHistory()
Delete the Turtle's previous history and clear all previous drawing.
|
boolean |
closeToPath(float distance)
Answer question: if Turtle moves forward a distance will it cross its
previous path.
|
void |
curveToPoint(float xInput,
float yInput) |
void |
curveToPoint2(float xInput,
float yInput,
float angleInput) |
float |
distanceFromPoint(float x,
float y)
Calculate Turtle's distance from a point.
|
void |
draw()
Draw method; draw Turtle's history to the screen.
|
void |
drawTurtle()
Draw the Turtle (a small blue triangle) on the screen.
|
void |
forward(float distance)
Move Turtle forward.
|
float |
getHeading()
Get the Turtle's current heading (angle).
|
int |
getPenState()
Get the Turtle's current pen state.
|
float |
getX()
Get the X coordinate of Turtle's current position.
|
float |
getY()
Get the Y coordinate of Turtle's current position.
|
void |
goToPoint(float xInput,
float yInput)
Jump Turtle to input point.
|
void |
left(float angle)
Turn Turtle to the left.
|
void |
penDown()
Set Turtle's pen state to PENDOWN.
|
void |
penUp()
Set Turtle's pen state to PENUP.
|
void |
pop()
Return Turtle to last saved state and remove ("pop") that state from the
stack.
|
void |
printTurtleHistory() |
void |
push()
Save ("push") Turtle's current state to the stack.
|
void |
right(float angle)
Turn Turtle to the right.
|
void |
setHeading(float theta)
Set the Turtle's current heading (angle).
|
void |
setPenState(int penStateInput)
Set the Turtle's current pen state.
|
void |
setWrapAround(boolean wrap)
Turn wrap-around on and off.
|
void |
setX(float x)
Set the X coordinate of Turtle's current position.
|
void |
setY(float y)
Set the Y coordinate of Turtle's current position.
|
public float currentX
public float currentY
public float currentTheta
public int currentPenState
public static final java.lang.String VERSION
public Turtle(processing.core.PApplet theParent)
theParent
- parent sketch in which Turtle is generated.public Turtle(Turtle T)
T
- creates a new Turtle using parameters from the input Turtle,
T.public void forward(float distance)
distance
- number of steps (maps to pixels) to move.public void back(float distance)
distance
- number of steps (maps to pixels) to move.public void right(float angle)
angle
- degrees to turn.public void left(float angle)
angle
- degrees to turn.public void penUp()
public void penDown()
public void push()
public void pop()
public float distanceFromPoint(float x, float y)
x
- x coordinate of point.y
- y coordinate of point.public boolean closeToPath(float distance)
distance
- distance to move forward.public float getX()
public float getY()
public float getHeading()
public int getPenState()
public void setX(float x)
x
- X coordinatepublic void setY(float y)
y
- Y coordinatepublic void setHeading(float theta)
theta
- angle input, in degreespublic void setPenState(int penStateInput)
penStateInput
- PENUP=1, PENDOWN=0, PENFAT=3public void setWrapAround(boolean wrap)
wrap
- public void goToPoint(float xInput, float yInput)
xInput
- X coordinate of pointyInput
- Y coordinate of pointpublic void curveToPoint2(float xInput, float yInput, float angleInput)
public void curveToPoint(float xInput, float yInput)
public void draw()
PApplet.noLoop()
. Will be
called automatically by Processing.public void printTurtleHistory()
public void clearTurtleHistory()
public void drawTurtle()
Processing Library Turtle by Leah Buechley. (c) 2016