N-gones - Slow version: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 15: Line 15:
<jsxgraph width="600" height="600">
<jsxgraph width="600" height="600">
var brd = JXG.JSXGraph.initBoard('jxgbox', {originX:300, originY:300, unitX:1, unitY:1});
var brd = JXG.JSXGraph.initBoard('jxgbox', {originX:300, originY:300, unitX:1, unitY:1});
//var t = brd.createElement('turtle',[],{fillColor:'yellow'});
var t = brd.createElement('turtle',[],{fillColor:'yellow'});
//var speed;
var speed;
/*
function innerloop(i,j,ne,sz) {
function innerloop(i,j,ne,sz) {
   if (i>0) {
   if (i>0) {
Line 36: Line 35:
   innerloop(ne,ne,ne,sz);
   innerloop(ne,ne,ne,sz);
}
}
*/
function runturtle() {
function runturtle() {
/*
   var code = $('inputtext').value;
   var code = $('inputtext').value;
   if (code=='') { return; }
   if (code=='') { return; }
   eval(code);
   eval(code);
*/
}
}
function clearturtle() {
function clearturtle() {

Revision as of 12:25, 26 February 2009


This example uses the JSXGraph MediaWiki extension.

<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>