L-systems: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 1: Line 1:
===Sierpinski curve===
<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" />
Line 34: Line 35:
var brd = [];
var brd = [];
brd[0] = JXG.JSXGraph.initBoard('box0', {originX: 300, originY: 300, unitX: 1, unitY: 1});
brd[0] = JXG.JSXGraph.initBoard('box0', {originX: 300, originY: 300, unitX: 1, unitY: 1});
t[0] = new JSXTurtleObj(brd[0]);
turtle[0] = new JSXTurtleObj(brd[0]);


function expander(level,axiom,rules) {
function expander(level,axiom,rules) {
Line 62: Line 63:
}
}


function plotter(generator,symbols,len,angle) {
function plotter(generator,symbols,len,angle,t) {
     for (var c; c=generator.next(); c) {
     for (var c; c=generator.next(); c) {
         switch(symbols[c]) {
         switch(symbols[c]) {
Line 103: Line 104:
   eval(code);
   eval(code);
   var generator = new expander(level,axiom,rules);
   var generator = new expander(level,axiom,rules);
   plotter(generator,symbols,len,angle);
   plotter(generator,symbols,len,angle,t);
   brd[nr].unsuspendUpdate();
   brd[nr].unsuspendUpdate();
}
}
Line 112: Line 113:
</script>
</script>
</html>
</html>
===Quadratic snowflake variation===
<html>
<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(1)">
</form>
<div id="box1" class="jxgbox" style="width:600px; height:600px;"></div>
<script language="JavaScript">
brd[1] = JXG.JSXGraph.initBoard('box1', {originX: 300, originY: 300, unitX: 1, unitY: 1});
turtle[1] = new JSXTurtleObj(brd[1]);
</script>
</html>
===Dragon curve===


[[Category:Examples]]
[[Category:Examples]]
[[Category:Turtle Graphics]]
[[Category:Turtle Graphics]]

Revision as of 19:41, 30 December 2008

Sierpinski curve


Quadratic snowflake variation


Dragon curve