N-gones - Slow version: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
(34 intermediate revisions by one other user not shown)
Line 1: Line 1:
<html>
<html>
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/prototype.js"></script>
<form><textarea id="inputtext" rows=5 cols=35 wrap="off" style="width:600px;">
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
speed=25;
<form><textarea id="inputtext" rows=12 cols=35 wrap="off" style="width:600px;">
t.cs().hideTurtle().setProperty({strokeWidth:4,strokeOpacity:0.6,fillOpacity:0.3});
function mn_eck(ne,sz) {
ngon(10,60);
  for(var i=0;i<ne;i++) {
    t.rt(360/ne);
    for(var j=0;j<ne;j++) {
      t.rt(360/ne);
      t.fd(sz);
    }
  }
}
 
t.cs();
t.setProperty({strokeWidth:4,strokeOpacity:0.6,fillOpacity:0.3});
t.hideTurtle();
mn_eck(36,20);
</textarea><br />
</textarea><br />
<input type="button" value="run" onClick="runturtle()">
<input type="button" value="run" onClick="runturtle()">
Line 24: Line 11:
</html>
</html>


<html>
<jsxgraph width="600" height="600">
<!--<jsxgraph width="600" height="600">-->
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-300, 300, 300, -300]});
<div id="jxgbox" class="jxgbox" style="width:600px; height:600px;"></div>
<script language="JavaScript">
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) {
  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() {
function runturtle() {
   brd.suspendUpdate();
   var code = document.getElementById('inputtext').value;
  if (code=='') { return; }
  eval(code);
}
function clearturtle() {
  t.cs();
}
</jsxgraph>
 
 
== Sourcecode ==
 
<source lang="javascript">
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);
  }
}


   var code = $('inputtext').value;
function ngon(ne,sz) {
  innerloop(ne,ne,ne,sz);
}
 
function runturtle() {
   var code = document.getElementById('inputtext').value;
   if (code=='') { return; }
   if (code=='') { return; }
   eval(code);
   eval(code);
  brd.unsuspendUpdate();
}
}
function clearturtle() {
function clearturtle() {
   t.cs();
   t.cs();
}
}
//runturtle();
</source>
</script>
<!--</jsxgraph>-->
</html>


[[Category:Examples]]
[[Category:Examples]]
[[Category:Turtle Graphics]]
[[Category:Turtle Graphics]]

Revision as of 09:56, 8 June 2011



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();
}