Multiple turtles: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 43: | Line 43: | ||
</html> | </html> | ||
=== | ===The underlying JavaScript code=== | ||
<source lang="javascript"> | |||
var brd = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 300, unitX: 1, unitY: 1}); | |||
var t1 = new JSXTurtleObj(brd); | |||
var t2 = new JSXTurtleObj(brd); | |||
t1.setPos(200,0); | |||
t2.setPos(0,0); | |||
var n = 64; | |||
var delta = 360.0/n; | |||
function chase() { | |||
t1.fd(20); | |||
t1.lt(delta); | |||
t2.lookTo(t1.pos); | |||
t2.fd(20); | |||
action = setTimeout(chase,100); | |||
} | |||
chase(); | |||
</source> | |||
[[Category:Examples]] | [[Category:Examples]] | ||
[[Category:Turtle Graphics]] | [[Category:Turtle Graphics]] |
Revision as of 18:29, 11 January 2009
Output
The underlying JavaScript code
var brd = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 300, unitX: 1, unitY: 1});
var t1 = new JSXTurtleObj(brd);
var t2 = new JSXTurtleObj(brd);
t1.setPos(200,0);
t2.setPos(0,0);
var n = 64;
var delta = 360.0/n;
function chase() {
t1.fd(20);
t1.lt(delta);
t2.lookTo(t1.pos);
t2.fd(20);
action = setTimeout(chase,100);
}
chase();