L-systems: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 31: Line 31:
var t = new JSXTurtleObj(brd);
var t = new JSXTurtleObj(brd);


var LSystem = "\
function expander(level) {
function expander(level) {
     this.source = (level>1) ? new expander(level-1) : (new function() {
     this.source = (level>1) ? new expander(level-1) : (new function() {
Line 56: Line 55:
}
}


function plotter() {
function plotter(generator) {
     for (var c; c=generator.next(); c) {
     for (var c; c=generator.next(); c) {
         switch(symbols[c]) {
         switch(symbols[c]) {
Line 87: Line 86:
     return null;
     return null;
}
}
";


function run() {
function run() {
Line 98: Line 96:
   eval(LSystem);
   eval(LSystem);
   var generator = new expander(level,axiom,rules);
   var generator = new expander(level,axiom,rules);
   plotter();
   plotter(generator);
   brd.unsuspendUpdate();
   brd.unsuspendUpdate();
}
}

Revision as of 18:34, 30 December 2008