Difference between revisions of "Slow the turtle down"

From JSXGraph Wiki
Jump to navigationJump to search
Line 1: Line 1:
 +
<html>
 +
<form><input type="button" value="run" onclick="run(10)"></form>
 +
</html>
 
<jsxgraph width="500" height="500">
 
<jsxgraph width="500" height="500">
 
var brd = JXG.JSXGraph.initBoard('jxgbox',{unitX:1, unitY:1, originX:250, originY:250});
 
var brd = JXG.JSXGraph.initBoard('jxgbox',{unitX:1, unitY:1, originX:250, originY:250});
 
var t = brd.createElement('turtle');
 
var t = brd.createElement('turtle');
  
 +
function run(n) {
 +
  if (n>=0) {
 +
    t.fd(20);
 +
    t.lt(12);
 +
    run(n-1);
 +
  }
 +
}
 
</jsxgraph>
 
</jsxgraph>
 
 
[[Category:Examples]]
 
[[Category:Examples]]
 
[[Category:Turtle Graphics]]
 
[[Category:Turtle Graphics]]

Revision as of 15:13, 25 February 2009