# JSXGraph 1.7.0 Reference

## JavaScript must be enabled in order for you to use JSXGraph and JSXGraph reference. However, it seems JavaScript is either disabled or not supported by your browser.

Class Index | File Index

Elements

Classes

- _global_
- Angle
- Arc
- Arrow
- Arrowparallel
- Axis
- Bisector
- Bisectorlines
- Boxplot
- Button
- Cardinalspline
- Chart
- Checkbox
- Circle
- Circumcenter
- Circumcircle
- CircumcircleArc
- CircumcircleSector
- Comb
- Conic
- Curve
- Curve3D
- CurveDifference
- CurveIntersection
- CurveUnion
- Derivative
- Ellipse
- ForeignObject
- Functiongraph
- Functiongraph3D
- Glider
- Grid
- Group
- Hatch
- Hyperbola
- Image
- ImplicitCurve
- Incenter
- Incircle
- Inequality
- Input
- Integral
- Intersection
- JXG
- JXG.AbstractRenderer
- JXG.Board
- JXG.Board.infobox
- JXG.C
- JXG.CA
- JXG.CanvasRenderer
- JXG.Chart
- JXG.Circle
- JXG.Complex
- JXG.Composition
- JXG.Coords
- JXG.CoordsElement
- JXG.Curve
- JXG.Curve3D
- JXG.Dump
- JXG.EventEmitter
- JXG.Expect
- JXG.ForeignObject
- JXG.GeometryElement
- JXG.GeometryElement3D
- JXG.GeonextParser
- JXG.Group
- JXG.Image
- JXG.JessieCode
- JXG.JSXGraph
- JXG.Legend
- JXG.Line
- JXG.Line3D
- JXG.Math
- JXG.Math.BoxQuadtree
- JXG.Math.Clip
- JXG.Math.Extrapolate
- JXG.Math.Geometry
- JXG.Math.ImplicitPlot
- JXG.Math.IntervalArithmetic
- JXG.Math.Metapost
- JXG.Math.Nlp
- JXG.Math.Numerics
- JXG.Math.Plot
- JXG.Math.Poly
- JXG.Math.Poly.Monomial
- JXG.Math.Poly.Polynomial
- JXG.Math.Poly.Ring
- JXG.Math.ProbFuncs
- JXG.Math.Quadtree
- JXG.Math.Statistics
- JXG.Math.Symbolic
- JXG.NoRenderer
- JXG.Options
- JXG.Plane3D
- JXG.Point
- JXG.Point3D
- JXG.Polygon
- JXG.PrefixParser
- JXG.Server
- JXG.Server.modules
- JXG.Surface3D
- JXG.SVGRenderer
- JXG.Text
- JXG.Ticks
- JXG.Transformation
- JXG.Turtle
- JXG.Util
- JXG.Util.Base64
- JXG.Util.Unzip
- JXG.Util.UTF8
- JXG.View3D
- JXG.VMLRenderer
- JXG.XML
- Label
- Legend
- Line
- Line3D
- Locus
- MajorArc
- MajorSector
- Measurement
- Metapostspline
- Midpoint
- MinorArc
- MinorSector
- mirrorelement
- Mirrorpoint
- NonReflexAngle
- Normal
- Orthogonalprojection
- OtherIntersection
- Parabola
- Parallel
- Parallelogram
- Parallelpoint
- ParametricSurface3D
- Perpendicular
- PerpendicularPoint
- PerpendicularSegment
- Point
- Point3D
- PolarLine
- PolePoint
- Polygon
- PolygonalChain
- RadicalAxis
- Reflection
- ReflexAngle
- RegularPolygon
- Riemannsum
- Sector
- Segment
- Semicircle
- Slider
- Slopefield
- Slopetriangle
- Smartlabel
- Spline
- Stepfunction
- Tangent
- Tapemeasure
- Text
- Ticks
- Tracecurve
- Transformation
- Turtle
- Vectorfield
- Vectorfield3D
- View3D

# Class JXG.Turtle

↳ JXG.Turtle

This is the Turtle class. It is derived from JXG.GeometryElement. It stores all properties required to move a turtle.
Defined in: turtle.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| JXG.Turtle(board, parents, attributes) Constructs a new Turtle object.

Method Summary
Method Attributes | Method Name and Description
--- | ---
| back(len) Move the turtle backwards.
| bk(len) Alias for JXG.Turtle#back
| clean() Removes the turtle curve from the board.
| clearScreen() Removes the turtle completely and resets it to its initial position and direction.
<private> | copyAttr(key, val) Set a future attribute of the turtle.
| cs() Alias for JXG.Turtle#clearScreen
| evalAt(t) The "co"-coordinate of the turtle curve at position t is returned.
| fd(len) Alias for JXG.Turtle#forward
| forward(len) Move the turtle forward.
| getHighlightPenColor() Get most recently set turtle color.
<private> | getPenAttribute(key) Get attribute of the last turtle curve object.
| getPenColor() Get most recently set turtle color.
| getPenSize() Get most recently set turtle size (in pixel).
| hasPoint(x, y) Checks whether (x,y) is near the curve.
| hideTurtle() Sets the visibility of the turtle head to false,
| home() Moves the turtle to position [0,0].
| ht() Alias for JXG.Turtle#hideTurtle
<private> | init(x, y, dir) Initialize a new turtle or reinitialize a turtle after JXG.Turtle#clearScreen.
| left(angle) Rotate the turtle direction to the right.
| lookTo(target) Rotates the turtle into a new direction.
| lt(angle) Alias for JXG.Turtle#left
| maxX() Gives the upper bound of the parameter if the turtle is treated as parametric curve.
| minX() Gives the lower bound of the parameter if the turtle is treated as parametric curve.
| moveTo(target) Moves the turtle to a given coordinate pair.
| pd() Alias for JXG.Turtle#penDown
| penDown() Pen down, continues visible drawing
| penUp() Pen up, stops visible drawing
| pop() Alias for JXG.Turtle#popTurtle
| popTurtle() Gets the last position of the turtle on the stack, sets the turtle to this position and removes this position from the stack.
| pu() Alias for JXG.Turtle#penUp
| push() Alias for JXG.Turtle#pushTurtle
| pushTurtle() Pushes the position of the turtle on the stack.
| right(angle) Rotate the turtle direction to the right
| rt(angle) Alias for JXG.Turtle#right
| setAttribute(attributes) Sets properties of the turtle, see also JXG.GeometryElement#setAttribute.
| setHighlightPenColor(color) Sets the highlight pen color.
| setPenColor(color) Sets the pen color.
| setPenSize(size) Sets the pen size.
| setPos(x, y) Moves the turtle without drawing to a new position
| showTurtle() Sets the visibility of the turtle head to true,
| st() Alias for JXG.Turtle#showTurtle
| X(t) if t is not supplied the x-coordinate of the turtle is returned.
| Y(t) if t is not supplied the y-coordinate of the turtle is returned.
| Z(t)

Class Detail
JXG.Turtle(board, parents, attributes)
Constructs a new Turtle object.

Parameters:
{JXG.Board} board
  The board the new turtle is drawn on.
{Array} parents
  Start position and start direction of the turtle. Possible values are [x, y, angle] [[x, y], angle] [x, y] [[x, y]]
{Object} attributes
  Attributes to change the visual properties of the turtle object All angles are in degrees.

Examples:

    //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();

Method Detail
{JXG.Turtle} back(len)
Move the turtle backwards.

Parameters:
{Number} len
  of backwards move in user coordinates

Returns:
  {JXG.Turtle} pointer to the turtle object

bk(len)
Alias for JXG.Turtle#back

Parameters:
len

{JXG.Turtle} clean()
Removes the turtle curve from the board. The turtle stays in its position.

Returns:
  {JXG.Turtle} pointer to the turtle object

{JXG.Turtle} clearScreen()
Removes the turtle completely and resets it to its initial position and direction.

Returns:
  {JXG.Turtle} pointer to the turtle object

<private> {Object} copyAttr(key, val)
Set a future attribute of the turtle.

Parameters:
{String} key
{Number|String} val

Returns:
  {Object} pointer to the attributes object

cs()
Alias for JXG.Turtle#clearScreen

{Number} evalAt(t)
The "co"-coordinate of the turtle curve at position t is returned.

Parameters:
{Number} t
  parameter
{String} co.
  Either 'X' or 'Y'.

Returns:
  {Number} x-coordinate of the turtle position or x-coordinate of turtle at position t

fd(len)
Alias for JXG.Turtle#forward

Parameters:
len

{JXG.Turtle} forward(len)
Move the turtle forward.

Parameters:
{Number} len
  of forward move in user coordinates

Returns:
  {JXG.Turtle} pointer to the turtle object

getHighlightPenColor()
Get most recently set turtle color.

Returns:
  String RGB highlight color value of the last turtle segment.

<private> getPenAttribute(key)
Get attribute of the last turtle curve object.

Parameters:
{String} key

Returns:
  attribute value

getPenColor()
Get most recently set turtle color.

Returns:
  String RGB color value of the last turtle segment.

getPenSize()
Get most recently set turtle size (in pixel).

Returns:
  Number Size of the last turtle segment in pixel.

{Boolean} hasPoint(x, y)
Checks whether (x,y) is near the curve.

Parameters:
{Number} x
  Coordinate in x direction, screen coordinates.
{Number} y
  Coordinate in y direction, screen coordinates.

Returns:
  {Boolean} True if (x,y) is near the curve, False otherwise.

{JXG.Turtle} hideTurtle()
Sets the visibility of the turtle head to false,

Returns:
  {JXG.Turtle} pointer to the turtle object

{JXG.Turtle} home()
Moves the turtle to position [0,0].

Returns:
  {JXG.Turtle} pointer to the turtle object

ht()
Alias for JXG.Turtle#hideTurtle

<private> init(x, y, dir)
Initialize a new turtle or reinitialize a turtle after JXG.Turtle#clearScreen.

Parameters:
x
y
dir

{JXG.Turtle} left(angle)
Rotate the turtle direction to the right.

Parameters:
{Number} angle
  of the rotation in degrees

Returns:
  {JXG.Turtle} pointer to the turtle object

{JXG.Turtle} lookTo(target)
Rotates the turtle into a new direction. There are two possibilities:

Parameters:
{Number|Array} target
  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:
  {JXG.Turtle} pointer to the turtle object

lt(angle)
Alias for JXG.Turtle#left

Parameters:
angle

maxX()
Gives the upper bound of the parameter if the turtle is treated as parametric curve. May be overwritten in @see generateTerm.

minX()
Gives the lower bound of the parameter if the turtle is treated as parametric curve.

{JXG.Turtle} moveTo(target)
Moves the turtle to a given coordinate pair. The direction is not changed.

Parameters:
{Array} target
  Coordinates of the point where the turtle looks to.

Returns:
  {JXG.Turtle} pointer to the turtle object

pd()
Alias for JXG.Turtle#penDown

{JXG.Turtle} penDown()
Pen down, continues visible drawing

Returns:
  {JXG.Turtle} pointer to the turtle object

{JXG.Turtle} penUp()
Pen up, stops visible drawing

Returns:
  {JXG.Turtle} pointer to the turtle object

pop()
Alias for JXG.Turtle#popTurtle

{JXG.Turtle} popTurtle()
Gets the last position of the turtle on the stack, sets the turtle to this position and removes this position from the stack.

Returns:
  {JXG.Turtle} pointer to the turtle object

pu()
Alias for JXG.Turtle#penUp

push()
Alias for JXG.Turtle#pushTurtle

{JXG.Turtle} pushTurtle()
Pushes the position of the turtle on the stack.

Returns:
  {JXG.Turtle} pointer to the turtle object

{JXG.Turtle} right(angle)
Rotate the turtle direction to the right

Parameters:
{Number} angle
  of the rotation in degrees

Returns:
  {JXG.Turtle} pointer to the turtle object

rt(angle)
Alias for JXG.Turtle#right

Parameters:
angle

{JXG.Turtle} setAttribute(attributes)
Sets properties 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:
{Object} attributes
  key:value pairs

Returns:
  {JXG.Turtle} pointer to the turtle object

{JXG.Turtle} setHighlightPenColor(color)
Sets the highlight pen color. Equivalent to setAttribute({highlightStrokeColor:color}) but affects only the future turtle.

Parameters:
{String} color

Returns:
  {JXG.Turtle} pointer to the turtle object

{JXG.Turtle} setPenColor(color)
Sets the pen color. Equivalent to setAttribute({strokeColor:color}) but affects only the future turtle.

Parameters:
{String} color

Returns:
  {JXG.Turtle} pointer to the turtle object

{JXG.Turtle} setPenSize(size)
Sets the pen size. Equivalent to setAttribute({strokeWidth:size}) but affects only the future turtle.

Parameters:
{Number} size

Returns:
  {JXG.Turtle} pointer to the turtle object

{JXG.Turtle} setPos(x, y)
Moves the turtle without drawing to a new position

Parameters:
{Number} x
  new x- coordinate
{Number} y
  new y- coordinate

Returns:
  {JXG.Turtle} pointer to the turtle object

{JXG.Turtle} showTurtle()
Sets the visibility of the turtle head to true,

Returns:
  {JXG.Turtle} pointer to the turtle object

st()
Alias for JXG.Turtle#showTurtle

{Number} X(t)
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:
{Number} t
  parameter

Returns:
  {Number} x-coordinate of the turtle position or x-coordinate of turtle at position t

{Number} Y(t)
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:
{Number} t
  parameter

Returns:
  {Number} x-coordinate of the turtle position or x-coordinate of turtle at position t

{Number} Z(t)

Parameters:
t

Returns:
  {Number} z-coordinate of the turtle position

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 14 2024 15:53:29 GMT+0100 (heure normale d’Europe centrale)