N-gones - Slow version: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 3: Line 3:
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/prototype.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/prototype.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<form><textarea id="inputtext" rows=8 cols=35 wrap="off" style="width:600px;">
<form><textarea id="inputtext" rows=5 cols=35 wrap="off" style="width:600px;">
speed=25;
speed=25;
t.cs().hideTurtle().setProperty({strokeWidth:4,strokeOpacity:0.6,fillOpacity:0.3});
t.cs().hideTurtle().setProperty({strokeWidth:4,strokeOpacity:0.6,fillOpacity:0.3});
ngon(7,60);
ngon(10,60);
</textarea><br />
</textarea><br />
<input type="button" value="run" onClick="runturtle()">
<input type="button" value="run" onClick="runturtle()">
Line 38: Line 38:


function runturtle() {
function runturtle() {
  //brd.suspendUpdate();
   var code = $('inputtext').value;
   var code = $('inputtext').value;
   if (code=='') { return; }
   if (code=='') { return; }
   eval(code);
   eval(code);
  //brd.unsuspendUpdate();
}
}
function clearturtle() {
function clearturtle() {
Line 76: Line 73:


function runturtle() {
function runturtle() {
  //brd.suspendUpdate();
   var code = $('inputtext').value;
   var code = $('inputtext').value;
   if (code=='') { return; }
   if (code=='') { return; }
   eval(code);
   eval(code);
  //brd.unsuspendUpdate();
}
}
function clearturtle() {
function clearturtle() {

Revision as of 16: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>