N-gones - Slow version: Difference between revisions
From JSXGraph Wiki
No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 13: | Line 13: | ||
<jsxgraph width="600" height="600"> | <jsxgraph width="600" height="600"> | ||
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-300, 300, 300, -300]}); | var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-300, 300, 300, -300]}); | ||
var t = brd. | var t = brd.create('turtle',[],{fillColor:'yellow'}); | ||
var speed; | var speed; | ||
function innerloop(i,j,ne,sz) { | function innerloop(i,j,ne,sz) { | ||
Line 48: | Line 48: | ||
<source lang="javascript"> | <source lang="javascript"> | ||
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-300, 300, 300, -300]}); | var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-300, 300, 300, -300]}); | ||
var t = brd. | var t = brd.create('turtle',[],{fillColor:'yellow'}); | ||
var speed; | var speed; | ||
Latest revision as of 13:34, 3 March 2021
Sourcecode
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-300, 300, 300, -300]});
var t = brd.create('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();
}