N-gones - Slow version

From JSXGraph Wiki
Revision as of 09:56, 8 June 2011 by Michael (talk | contribs)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.



Sourcecode

var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-300, 300, 300, -300]});
var t = brd.createElement('turtle',[],{fillColor:'yellow'});
var speed;

function innerloop(i,j,ne,sz) {
   if (i>0) {
     if (j==ne) { t.rt(360/ne); }
     t.rt(360/ne);
     t.fd(sz);
     j--;
     if (j<=0) {
       j=ne;
       i--;
     }
     var st = 'innerloop('+(i)+','+(j)+','+(ne)+','+(sz)+')';
     setTimeout(st,speed);
   }
}

function ngon(ne,sz) {
  innerloop(ne,ne,ne,sz);
}

function runturtle() {
  var code = document.getElementById('inputtext').value;
  if (code=='') { return; }
  eval(code);
}
function clearturtle() {
  t.cs();
}