Difference between revisions of "N-gones - Slow version"

From JSXGraph Wiki
Jump to navigationJump to search
Line 28: Line 28:
 
       i--;
 
       i--;
 
     }
 
     }
     var st = 'innerloop('+(i)+','+(j)+','+ne+','+sz+')';
+
     var st = 'innerloop('+(i)+','+(j)+','+(ne)+','+(sz)+')';
 
     setTimeout(st,speed);
 
     setTimeout(st,speed);
 
   }
 
   }
Line 63: Line 63:
 
       i--;
 
       i--;
 
     }
 
     }
     var st = 'innerloop('+(i)+','+(j)+','+ne+','+sz+')';
+
     var st = 'innerloop('+(i)+','+(j)+','+(ne)+','+(sz)+')';
 
     setTimeout(st,speed);
 
     setTimeout(st,speed);
 
   }
 
   }

Revision as of 18:11, 25 February 2009


<jsxgraph width="600" height="600">-->
var brd = JXG.JSXGraph.initBoard('jxgbox', {originX:300, originY:300, unitX:1, unitY:1});
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 = $('inputtext').value;
  if (code=='') { return; }
  eval(code);
}
function clearturtle() {
  t.cs();
}
</jsxgraph>