Turtle animation of the "8": Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 3: Line 3:
var t = brd.create('turtle',[0, 0], {});
var t = brd.create('turtle',[0, 0], {});
t.setPenSize(3);
t.setPenSize(3);
t.right(90);
var alpha = 0;
   
   
var run = function() {
var run = function() {
   t.fd(2);
   t.fd(2);
   t.lt(1);
   if (Math.floor(alpha / 360) % 2) === 0) {
      t.left(1);
  } else {
      t.right(1);
  }
 
  alpha += 1;
   setTimeout(run,25);
   setTimeout(run,25);
}
}

Revision as of 07:38, 28 August 2013