Turtle spiral: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
No edit summary |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<html> | <html> | ||
<form><textarea id="inputtext" rows=5 cols=35 wrap="off" style="width:600px;">for (var i=0;i< | <form><textarea id="inputtext" rows=5 cols=35 wrap="off" style="width:600px;">for (var i=0;i<100;i++){ | ||
t.forward(i* | t.forward(i*3); | ||
t.left(71); | t.left(71); | ||
} | } | ||
Line 11: | Line 11: | ||
<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'); | ||
function run() { | function run() { | ||
brd.suspendUpdate(); | brd.suspendUpdate(); | ||
var code = | var code = document.getElementById('inputtext').value; | ||
if (code=='') { return; } | if (code=='') { return; } | ||
eval(code); | eval(code); | ||
Line 24: | Line 24: | ||
t.cs(); | t.cs(); | ||
} | } | ||
run(); | |||
</jsxgraph> | </jsxgraph> | ||
===Source code=== | ===Source code=== | ||
<source lang=" | <source lang="javascript"> | ||
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-300, 300, 300, -300]}); | |||
var brd = JXG.JSXGraph.initBoard('jxgbox', { | var t = brd.create('turtle'); | ||
var t = brd. | |||
function run() { | function run() { | ||
brd.suspendUpdate(); | brd.suspendUpdate(); | ||
var code = | var code = document.getElementById('inputtext').value; | ||
if (code=='') { return; } | if (code=='') { return; } | ||
eval(code); | eval(code); | ||
Line 42: | Line 42: | ||
t.cs(); | t.cs(); | ||
} | } | ||
run(); | |||
</source> | </source> | ||
Line 48: | Line 48: | ||
===External links=== | ===External links=== | ||
* [http://www.geogebra.org/de/wiki/index.php/Turtlegrafik | * [http://www.geogebra.org/de/wiki/index.php/Turtlegrafik A similar construction with GeoGebra] | ||
* [http://wiki.zum.de/Turtle-Grafik ZUM-Wiki's Turtle graphics page] | * [http://wiki.zum.de/Turtle-Grafik ZUM-Wiki's Turtle graphics page] | ||
[[Category:Examples]] | [[Category:Examples]] | ||
[[Category:Turtle Graphics]] | [[Category:Turtle Graphics]] |
Latest revision as of 07:41, 9 June 2011
Source code
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-300, 300, 300, -300]});
var t = brd.create('turtle');
function run() {
brd.suspendUpdate();
var code = document.getElementById('inputtext').value;
if (code=='') { return; }
eval(code);
brd.unsuspendUpdate();
}
function clearturtle() {
t.cs();
}
run();
- Hints how to "Slow the turtle down"