L-systems: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 5: Line 5:
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxturtle.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxturtle.js"></script>
<form><textarea id="inputtext1" rows=3 cols=35 wrap="off" style="width:600px;">
<form><textarea id="inputtext1" rows=3 cols=35 wrap="off" style="width:600px;">
</textarea><br />
<input type="button" value="run" onClick="run(1)">
<input type="button" value="clear" onClick="clearturtle()">
var level = 6;
var level = 6;
var axiom = 'A';
var axiom = 'A';
var rules = {
var rules = {
     'A':'B-A-B',  
     'A':'B-A-B',
     'B':'A+B+A',
     'B':'A+B+A';
     '+' : '+',
     '+' : '+',
     '-' : '-'
     '-' : '-'
Line 15: Line 18:
var symbols = { 'A':'F',  
var symbols = { 'A':'F',  
                 'B':'F',  
                 'B':'F',  
                 '+':'+',
                 '+':'+',  
                 '-':'-',
                 '-':'-',  
                 '[':'[',
                 '[':'[',  
                 ']':']'
                 ']':']'
               } ;
               };  
var angle = 60;
var angle = 60;  
var len = 500/Math.pow(2,level);
var len = 500/Math.pow(2,level);  
t.setPos(-250*Math.pow(-1,level),-250);
t.setPos(-250*Math.pow(-1,level),-250);  
t.rt(90*Math.pow(-1,level));
t.rt(90*Math.pow(-1,level));  
</textarea><br />
<input type="button" value="run" onClick="run(1)">
<input type="button" value="clear" onClick="clearturtle()">
</form>
</form>
<div id="box" class="jxgbox" style="width:600px; height:600px;"></div>
<div id="box" class="jxgbox" style="width:600px; height:600px;"></div>

Revision as of 19:30, 30 December 2008


var level = 6; var axiom = 'A'; var rules = { 'A':'B-A-B', 'B':'A+B+A'; '+' : '+', '-' : '-' }; var symbols = { 'A':'F', 'B':'F', '+':'+', '-':'-', '[':'[', ']':']' }; var angle = 60; var len = 500/Math.pow(2,level); t.setPos(-250*Math.pow(-1,level),-250); t.rt(90*Math.pow(-1,level));