# JSXGraph 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
- Button
- Cardinalspline
- Checkbox
- Circle
- Circumcenter
- Circumcircle
- CircumcircleArc
- CircumcircleSector
- Conic
- Curve
- Derivative
- Ellipse
- Functiongraph
- Glider
- Grid
- Group
- Hatch
- Hyperbola
- Image
- Incenter
- Incircle
- Inequality
- Input
- Integral
- Intersection
- JXG
- JXG.AbstractRenderer
- JXG.Board
- JXG.C
- JXG.CA
- JXG.CanvasRenderer
- JXG.Circle
- JXG.Complex
- JXG.Composition
- JXG.Coords
- JXG.CoordsElement
- JXG.Curve
- JXG.Dump
- JXG.EventEmitter
- JXG.GeometryElement
- JXG.GeonextParser
- JXG.Group
- JXG.Image
- JXG.JessieCode
- JXG.JSXGraph
- JXG.Line
- JXG.Math
- JXG.Math.Geometry
- JXG.Math.Numerics
- JXG.Math.Poly
- JXG.Math.Poly.Monomial
- JXG.Math.Poly.Polynomial
- JXG.Math.Poly.Ring
- JXG.Math.Statistics
- JXG.Math.Symbolic
- JXG.NoRenderer
- JXG.Options
- JXG.Point
- JXG.Polygon
- JXG.Server
- JXG.Server.modules
- JXG.SVGRenderer
- JXG.Text
- JXG.Ticks
- JXG.Transformation
- JXG.Turtle
- JXG.Util
- JXG.Util.Base64
- JXG.Util.Unzip
- JXG.Util.UTF8
- JXG.VMLRenderer
- JXG.XML
- Label
- Line
- Locus
- MajorArc
- MajorSector
- Midpoint
- MinorArc
- MinorSector
- Mirrorelement
- Mirrorpoint
- NonReflexAngle
- Normal
- Orthogonalprojection
- OtherIntersection
- Parabola
- Parallel
- Parallelpoint
- Perpendicular
- PerpendicularPoint
- PerpendicularSegment
- Point
- PolarLine
- PolePoint
- Polygon
- Quadtree
- RadicalAxis
- Reflection
- ReflexAngle
- RegularPolygon
- Riemannsum
- Sector
- Segment
- Semicircle
- Slider
- Slopetriangle
- Spline
- Stepfunction
- Tangent
- Tapemeasure
- Text
- Ticks
- Tracecurve
- Transformation
- Turtle

# 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.
| 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 the turtle is treated as parametric curve.
| minX() Gives the lower bound of the parameter if the 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.

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

{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 the turtle is treated as parametric curve. May be overwritten in @see generateTerm.

minX()
Gives the lower bound of the parameter if the 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