Methods
Own
X(t) → {Number}
if t is not supplied the x-coordinate of the turtle is returned. Otherwise the x-coordinate of the turtle curve at position t is returned.
Parameters
| Name | Type | Description |
|---|---|---|
t |
Number | parameter |
Returns
x-coordinate of the turtle position or x-coordinate of turtle at position t
- Type
- Number
Details
- Source
- base/turtle.js, line 841
Y(t) → {Number}
if t is not supplied the y-coordinate of the turtle is returned. Otherwise the y-coordinate of the turtle curve at position t is returned.
Parameters
| Name | Type | Description |
|---|---|---|
t |
Number | parameter |
Returns
x-coordinate of the turtle position or x-coordinate of turtle at position t
- Type
- Number
Details
- Source
- base/turtle.js, line 855
Z() → {Number}
Returns
z-coordinate of the turtle position
- Type
- Number
Details
- Source
- base/turtle.js, line 865
back(len) → {JXG.Turtle}
Move the turtle backwards.
Parameters
| Name | Type | Description |
|---|---|---|
len |
Number | of backwards move in user coordinates |
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 330
clean() → {JXG.Turtle}
Removes the turtle curve from the board. The turtle stays in its position.
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 394
clearScreen() → {JXG.Turtle}
Removes the turtle completely and resets it to its initial position and direction.
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 420
(private) copyAttr(key, val) → {Object}
Set a future attribute of the turtle.
Parameters
| Name | Type | Description |
|---|---|---|
key |
String | |
val |
Number | String |
Returns
pointer to the attributes object
- Type
- Object
Details
- Source
- base/turtle.js, line 602
evalAt(t) → {Number}
The "co"-coordinate of the turtle curve at position t is returned.
Parameters
| Name | Type | Description |
|---|---|---|
t |
Number | parameter |
co. |
String | Either 'X' or 'Y'. |
Returns
x-coordinate of the turtle position or x-coordinate of turtle at position t
- Type
- Number
Details
- Source
- base/turtle.js, line 813
forward(len) → {JXG.Turtle}
Move the turtle forward.
Parameters
| Name | Type | Description |
|---|---|---|
len |
Number | of forward move in user coordinates |
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 285
getHighlightPenColor()
Get most recently set turtle color.
Returns
String RGB highlight color value of the last turtle segment.
Details
- Source
- base/turtle.js, line 545
(private) getPenAttribute(key)
Get attribute of the last turtle curve object.
Parameters
| Name | Type | Description |
|---|---|---|
key |
String |
Returns
attribute value
Details
- Source
- base/turtle.js, line 514
getPenColor()
Get most recently set turtle color.
Returns
String RGB color value of the last turtle segment.
Details
- Source
- base/turtle.js, line 537
getPenSize()
Get most recently set turtle size (in pixel).
Returns
Number Size of the last turtle segment in pixel.
Details
- Source
- base/turtle.js, line 529
hasPoint(x, y) → {Boolean}
Checks whether (x,y) is near the curve.
Parameters
| Name | Type | Description |
|---|---|---|
x |
Number | Coordinate in x direction, screen coordinates. |
y |
Number | Coordinate in y direction, screen coordinates. |
Returns
True if (x,y) is near the curve, False otherwise.
- Type
- Boolean
Details
- Source
- base/turtle.js, line 901
hideTurtle() → {JXG.Turtle}
Sets the visibility of the turtle head to false,
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 625
home() → {JXG.Turtle}
Moves the turtle to position [0,0].
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 638
(private) init()
Initialize a new turtle or reinitialize a turtle after JXG.Turtle#clearScreen.
Details
- Source
- base/turtle.js, line 228
left(angle) → {JXG.Turtle}
Rotate the turtle direction to the right.
Parameters
| Name | Type | Description |
|---|---|---|
angle |
Number | of the rotation in degrees |
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 361
lookTo(target) → {JXG.Turtle}
Rotates the turtle into a new direction. There are two possibilities:
Parameters
| Name | Type | Description |
|---|---|---|
target |
Number | Array | If a number is given, it is interpreted as the new direction to look to; If an array consisting of two Numbers is given targeted is used as a pair coordinates. |
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 677
maxX()
Gives the upper bound of the parameter if the turtle is treated as parametric curve. May be overwritten in @see generateTerm.
Details
- Source
- base/turtle.js, line 880
minX()
Gives the lower bound of the parameter if the turtle is treated as parametric curve.
Details
- Source
- base/turtle.js, line 872
moveTo(target) → {JXG.Turtle}
Moves the turtle to a given coordinate pair. The direction is not changed.
Parameters
| Name | Type | Description |
|---|---|---|
target |
Array | Coordinates of the point where the turtle looks to. |
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 701
penDown() → {JXG.Turtle}
Pen down, continues visible drawing
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 378
penUp() → {JXG.Turtle}
Pen up, stops visible drawing
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 369
popTurtle() → {JXG.Turtle}
Gets the last position of the turtle on the stack, sets the turtle to this position and removes this position from the stack.
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 660
pushTurtle() → {JXG.Turtle}
Pushes the position of the turtle on the stack.
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 649
right(angle) → {JXG.Turtle}
Rotate the turtle direction to the right
Parameters
| Name | Type | Description |
|---|---|---|
angle |
Number | of the rotation in degrees |
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 339
setAttribute(attributes) → {JXG.Turtle}
Sets attributes of the turtle, see also JXG.GeometryElement#setAttribute. Sets the property for all curves of the turtle in the past and in the future.
Parameters
| Name | Type | Description |
|---|---|---|
attributes |
Object | key:value pairs |
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 572
setHighlightPenColor(color) → {JXG.Turtle}
Sets the highlight pen color. Equivalent to setAttribute({highlightStrokeColor:color}) but affects only the future turtle.
Parameters
| Name | Type | Description |
|---|---|---|
color |
String |
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 555
setPenColor(color) → {JXG.Turtle}
Sets the pen color. Equivalent to setAttribute({strokeColor:color}) but affects only the future turtle.
Parameters
| Name | Type | Description |
|---|---|---|
color |
String |
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 496
setPenSize(size) → {JXG.Turtle}
Sets the pen size. Equivalent to setAttribute({strokeWidth:size}) but affects only the future turtle.
Parameters
| Name | Type | Description |
|---|---|---|
size |
Number |
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 479
setPos(x, y) → {JXG.Turtle}
Moves the turtle without drawing to a new position
Parameters
| Name | Type | Description |
|---|---|---|
x |
Number | new x- coordinate |
y |
Number | new y- coordinate |
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 442
showTurtle() → {JXG.Turtle}
Sets the visibility of the turtle head to true,
Returns
pointer to the turtle object
- Type
- JXG.Turtle
Details
- Source
- base/turtle.js, line 611
Inherited
none
Example
Creates a figure 8 animation
var board = JXG.JSXGraph.initBoard('jxgbox',{boundingbox: [-250, 250, 250, -250]});
var t = board.create('turtle',[0, 0], {strokeOpacity:0.5});
t.setPenSize(3);
t.right(90);
var alpha = 0;
var run = function() {
t.forward(2);
if (Math.floor(alpha / 360) % 2 === 0) {
t.left(1); // turn left by 1 degree
} else {
t.right(1); // turn right by 1 degree
}
alpha += 1;
if (alpha < 1440) { // stop after two rounds
setTimeout(run, 20);
}
}
run();
Parameters
| Name | Type | Description |
|---|---|---|
board |
JXG.Board | The board the new turtle is drawn on. |
parents |
Array | Start position and start direction of the turtle. Possible values are |
attributes |
Object | Attributes to change the visual properties of the turtle object All angles are in degrees. |
Details
- Source
- base/turtle.js, line 118