Multiple turtles: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<html> | <html> | ||
<form><textarea id="inputtext" rows=3 cols=35 wrap="off" style="width:600px;"> | <form><textarea id="inputtext" rows=3 cols=35 wrap="off" style="width:600px;"> | ||
t1.setPos(200,0); | t1.setPos(200,0); | ||
Line 20: | Line 18: | ||
</form> | </form> | ||
</html> | </html> | ||
===Output=== | ===Output=== | ||
< | <jsxgraph box="box" width="600" height="600"> | ||
var brd = JXG.JSXGraph.initBoard('box', {boundingbox: [-300, 300, 300, -300]}); | |||
var brd = JXG.JSXGraph.initBoard('box', { | |||
var t1 = brd.createElement('turtle'); | var t1 = brd.createElement('turtle'); | ||
var t2 = brd.createElement('turtle'); | var t2 = brd.createElement('turtle'); | ||
Line 38: | Line 35: | ||
t2.cs(); | t2.cs(); | ||
} | } | ||
</ | </jsxgraph> | ||
===The underlying JavaScript code=== | ===The underlying JavaScript code=== | ||
<source lang="javascript"> | <source lang="javascript"> | ||
var brd = JXG.JSXGraph.initBoard('box', { | var brd = JXG.JSXGraph.initBoard('box', {boundingbox: [-300, 300, 300, -300]}); | ||
var t1 = brd.createElement('turtle'); | var t1 = brd.createElement('turtle'); | ||
var t2 = brd.createElement('turtle'); | var t2 = brd.createElement('turtle'); |
Revision as of 09:36, 8 June 2011
Output
The underlying JavaScript code
var brd = JXG.JSXGraph.initBoard('box', {boundingbox: [-300, 300, 300, -300]});
var t1 = brd.createElement('turtle');
var t2 = brd.createElement('turtle');
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();