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

From JSXGraph Wiki
Jump to navigationJump to search
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=12 cols=35 wrap="off" style="width:600px;">
speed=50;
+
/*
 +
function mn_eck(ne,sz) {
 +
  for(var i=ne;i>0;i--) {
 +
    t.rt(360/ne);
 +
    for(var j=ne;j>0;j--) {
 +
      t.rt(360/ne);
 +
      t.fd(sz);
 +
    }
 +
  }
 +
}
 +
*/
 +
 
 +
function mn_eck(ne,sz) {
 +
outerloop(ne,sz);
 +
}
 +
 
 
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,80);
+
mn_eck(7,80);
 
</textarea><br />
 
</textarea><br />
 
<input type="button" value="run" onClick="runturtle()">
 
<input type="button" value="run" onClick="runturtle()">
Line 16: Line 31:
 
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;
 
  
function innerloop(i,j,ne,sz) {
+
function outerloop(i,ne,sz) {
 
   if (i>0) {
 
   if (i>0) {
    if (j==ne) { t.rt(360/ne); }
 
 
     t.rt(360/ne);
 
     t.rt(360/ne);
     t.fd(sz);
+
     for(var j=ne;j>0;j--) {
    j--;
+
       t.rt(360/ne);
    if (j<=0) {
+
       t.fd(sz);
       j=ne;
 
       i--;
 
 
     }
 
     }
     var st = 'innerloop('+(i)+','+(j)+','+ne+','+sz+')';
+
     var st = 'outerloop('+(i-1)+','+ne+','+sz+')';
     //alert(st);
+
     alert(st);
     setTimeout(st,speed);
+
     setTimeout(st,25);
 
   }
 
   }
 
}
 
}
  
function ngon(ne,sz) {
 
  innerloop(ne,ne,ne,sz);
 
}
 
  
 
function runturtle() {
 
function runturtle() {

Revision as of 18:07, 25 February 2009