Difference between revisions of "N-gones - Slow version"
From JSXGraph Wiki
Jump to navigationJump to searchA WASSERMANN (talk | contribs) m (Slow version moved to N-gones - Slow version) |
A WASSERMANN (talk | contribs) |
||
(11 intermediate revisions by 2 users 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" /> | ||
− | |||
− | |||
<form><textarea id="inputtext" rows=5 cols=35 wrap="off" style="width:600px;"> | <form><textarea id="inputtext" rows=5 cols=35 wrap="off" style="width:600px;"> | ||
speed=25; | speed=25; | ||
Line 13: | Line 11: | ||
</html> | </html> | ||
− | <jsxgraph width="600" height="600" | + | <jsxgraph width="600" height="600"> |
− | var brd = JXG.JSXGraph.initBoard('jxgbox', { | + | 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) { | ||
if (i>0) { | if (i>0) { | ||
Line 36: | Line 33: | ||
innerloop(ne,ne,ne,sz); | innerloop(ne,ne,ne,sz); | ||
} | } | ||
− | |||
function runturtle() { | function runturtle() { | ||
− | var code = | + | var code = document.getElementById('inputtext').value; |
if (code=='') { return; } | if (code=='') { return; } | ||
eval(code); | eval(code); | ||
Line 47: | Line 43: | ||
</jsxgraph> | </jsxgraph> | ||
− | <source lang=" | + | |
− | + | == Sourcecode == | |
− | var brd = JXG.JSXGraph.initBoard('jxgbox', { | + | |
− | var t = brd. | + | <source lang="javascript"> |
+ | var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-300, 300, 300, -300]}); | ||
+ | var t = brd.create('turtle',[],{fillColor:'yellow'}); | ||
var speed; | var speed; | ||
Line 73: | Line 71: | ||
function runturtle() { | function runturtle() { | ||
− | var code = | + | var code = document.getElementById('inputtext').value; |
if (code=='') { return; } | if (code=='') { return; } | ||
eval(code); | eval(code); | ||
Line 80: | Line 78: | ||
t.cs(); | t.cs(); | ||
} | } | ||
− | |||
</source> | </source> | ||
[[Category:Examples]] | [[Category:Examples]] | ||
[[Category:Turtle Graphics]] | [[Category:Turtle Graphics]] |
Latest revision as of 15: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();
}