L-systems: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 25: | Line 25: | ||
t.rt(90*Math.pow(-1,level)); | t.rt(90*Math.pow(-1,level)); | ||
</textarea><br /> | </textarea><br /> | ||
<input type="button" value="run" onClick="run( | <input type="button" value="run" onClick="run(0)"> | ||
<input type="button" value="clear" onClick="clearturtle()"> | <input type="button" value="clear" onClick="clearturtle(0)"> | ||
</form> | </form> | ||
<div id=" | <div id="box0" class="jxgbox" style="width:600px; height:600px;"></div> | ||
<script language="JavaScript"> | <script language="JavaScript"> | ||
var | var brd0 = JXG.JSXGraph.initBoard('box0', {originX: 300, originY: 300, unitX: 1, unitY: 1}); | ||
var t = new JSXTurtleObj( | var t; | ||
var turtle = []; | |||
t[0] = new JSXTurtleObj(brd0); | |||
function expander(level,axiom,rules) { | function expander(level,axiom,rules) { | ||
Line 95: | Line 97: | ||
var code = $('inputtext'+nr).value; | var code = $('inputtext'+nr).value; | ||
if (code=='') { return; } | if (code=='') { return; } | ||
t = turtle[nr]; | |||
t.cs(); | t.cs(); | ||
t.hideTurtle(); | t.hideTurtle(); | ||
Line 103: | Line 106: | ||
} | } | ||
function clearturtle() { | function clearturtle(nr) { | ||
turtle[nr].cs(); | |||
} | } | ||
</script> | </script> |
Revision as of 19:38, 30 December 2008