Turtle

Element

A turtle is a graphic paradigm similar to the programming languages Logo or PostScript.

Usage (signatures)
board.create('turtle', [x, y, angleopt]);

Start position and start direction of the turtle.

Parameters
Name Type Attributes Default Description
x NumberLike
y NumberLike
angle NumberLike <optional>
90
Example

Animation of an 8

var board = JXG.JSXGraph.initBoard('jxgbox',{boundingbox: [-250, 250, 250, -250]});
var t = board.create('turtle', [0, 0], {
    strokeOpacity:0.5, strokeColor: 'blue', strokeWidth: 4
});
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();

board.create('turtle', [coords, angleopt]);

Start position and start direction of the turtle.

Parameters
Name Type Attributes Default Description
coords Array

Array [x, y] with start position

angle NumberLike <optional>
90
Attributes

Own

arrow

Description

Attributes for the turtle arrow.

Type
Curve
Source
options.js, line 10893

Inherited

none

Methods

Own

none

Inherited

Details

Type
JXG.Turtle
Source
base/turtle.js, line 921

Extends