diff options
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | lsys.js | 6 |
2 files changed, 7 insertions, 3 deletions
@@ -8,8 +8,8 @@ Usage ----- ```js -var lsys = new LSystem('F', { 'F' : 'F-F+FF' }); -var tree = lsys.iterate(2); +var lsys = new LSystem('F', { 'F' : 'F-F+FF' }).iterate(2); +var tree = lsys.print(); console.log(tree); // F-F+FF-F-F+FF+F-F+FFF-F+FF var coords = lsys.draw(Math.PI / 2); // draw tree with alpha as 90 degrees console.log(coords); // [[0,0,0], [0,1,0], [1,1,0], ... @@ -9,6 +9,10 @@ function LSystem(axiom, rules) { return rules[c] || c; }); } + return this; + }; + + this.print = function() { return this.tree; }; @@ -125,7 +129,7 @@ function LSystem(axiom, rules) { this.reset = function() { this.tree = axiom; - return this.tree; + return this; }; this.debug = function() { |
