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);


function run() {
  brd.suspendUpdate();
  var code = $('inputtext').value;
  if (code=='') { return; }
  t.cs();
  t.hideTurtle();
  eval(code);
  alert(axiom);
   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 62: Line 54:
     }
     }
   }
   }
  var generator = new expander(level);
   function plotter(generator) {
   function plotter(generator) {
     for (var c; c=generator.next(); c) {
     for (var c; c=generator.next(); c) {
Line 95: Line 86:
   }
   }


function run() {
  brd.suspendUpdate();
  var code = $('inputtext').value;
  if (code=='') { return; }
  t.cs();
  t.hideTurtle();
  eval(code);
  var generator = new expander(level);
   plotter(generator);
   plotter(generator);
   brd.unsuspendUpdate();
   brd.unsuspendUpdate();

Revision as of 18:41, 30 December 2008