Package com.kinabaloo.turtle
Class Turtle
To create objects of this class use method :
Turtle createTurtle()
defined in class TurtleFrame.
This class provides many methods for moving the turtle around the screen and defining how and when it draws a trailing line ('trace').
There are methods for moving the turtle in steps in just four directions around a grid, and for moving the turtle in all directions with pixel or better accuracy.
Fields
Protected
Color col =Color.black double dir =0 Paper paper boolean pen =true int step =1 int width =1 double x =300 double y =160
Methods
Public
public void backward(int d) Moves the turtle in the opposite direction to the currently specified angle.
@param d : distance to move (and draw if in drawing mode)public void backward(double d) Moves the turtle in the opposite direction to the currently specified angle.
@param d : distance to move (and draw if in drawing mode)public void down(int n) Moves the turtle in the left direction (180 degrees).
(Does not change the currently set angle used with
relative movement of the turtle)
@param n : number of steps to take, where a 'step' is equal to
the currently specified step sizepublic void drawToXY(double x, double y) Moves the turtle to position x, y while drawing
public void drawToXY(int x, int y) Moves the turtle to position x, y while drawing
public void forward(double d) Moves the turtle in the direction of the currently specified angle.
@param d : distance to move (and draw if in drawing mode)public void forward(int d) Moves the turtle in the direction of the currently specified angle.
@param d : distance to move (and draw if in drawing mode)public int getStepSize() returns : the number of grid steps to one turtle step
(1 to 4)public int getX() @returns : the current horizontal x position of the turtle
In Java, position 0, 0 is the top left corner of the screen.
The starting position of the turtle is 300, 160.public double getXD() @returns : the current horizontal x position of the turtle
In Java, position 0, 0 is the top left corner of the screen.
The starting position of the turtle is 300, 160.public int getY() @returns : the current vertical y position of the turtle
In Java, position 0, 0 is the top left corner of the screen.
The starting position of the turtle is 300, 160.public double getYD() @returns : the current vertical y position of the turtle
In Java, position 0, 0 is the top left corner of the screen.
The starting position of the turtle is 300, 160.public void goDown() Moves the turtle in the down direction (180 degrees).
(Does not change the currently set angle used with
relative movement of the turtle)public void goLeft() Moves the turtle in the left direction (270 degrees).
(Does not change the currently set angle used with
relative movement of the turtle)public void goRight() Moves the turtle in the right direction (90 degrees).
(Does not change the currently set angle used with
relative movement of the turtle)public void goUp() Moves the turtle in the up direction (0 degrees).
(Does not change the currently set angle used with
relative movement of the turtle)public void gotoXY(int x, int y) Moves the turtle to position x, y without drawing
public void gotoXY(double x, double y) Moves the turtle to position x, y without drawing
public boolean isDrawing() @returns : whether turtle draws a line behind it as it moves
public void left(int n) Moves the turtle in the left direction (270 degrees).
(Does not change the currently set angle used with
relative movement of the turtle)
@param n : number of steps to take, where a 'step' is equal to
the currently specified step sizepublic void right(int n) Moves the turtle in the right direction (90 degrees).
(Does not change the currently set angle used with
relative movement of the turtle)
@param n : number of steps to take, where a 'step' is equal to
the currently specified step sizepublic void setAngle(int angle) @param angle : in degrees (0 - 360)
public void setAngle(double angle) @param angle : in degrees (0.0 - 360.0)
public void setColor(Color color) @param color : the color of the line drawn by the turtle
public void setDrawing(boolean draw) @param draw : whether turtle draws a line behind it as it moves
public void setLineWidth(int w) @param w : 1 (thin), 2 (medium) or 3 (thick)
public void setStepSize(int size) param size : the number of grid steps to one turtle step
(1 to 4)public void turnLeft(double angle) @param angle : in degrees (0.0 - 360.0).
The turn is relative to the current angle.
The resultant angle becomes the new current angle.public void turnLeft(int angle) @param angle : in degrees (0 - 360).
The turn is relative to the current angle.
The resultant angle becomes the new current angle.public void turnRight(double angle) @param angle : in degrees (0.0 - 360.0).
The turn is relative to the current angle.
The resultant angle becomes the new current angle.public void turnRight(int angle) @param angle : in degrees (0 - 360).
The turn is relative to the current angle.
The resultant angle becomes the new current angle.public void up(int n) Moves the turtle in the up direction (0 degrees).
(Does not change the currently set angle used with
relative movement of the turtle)
@param n : number of steps to take, where a 'step' is equal to
the currently specified step sizeProtected
protected void delay()