summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2012-05-21 13:42:37 +0300
committerYuval Adam <yuv.adm@gmail.com>2012-05-21 13:42:37 +0300
commit029f1aa1d0b18f761268c823971053af68064f8c (patch)
treebce7829d62ca7d4c091437f56112bb5770e507bf
parenta6ee1cd24deed4d69fb092259812d8daa2ace716 (diff)
parent007b3be9d09121d9fe0ffb7303bf5438e821fb61 (diff)
Merge branch 'master' into gh-pages
Conflicts: index.html
-rw-r--r--README.md4
-rw-r--r--lsys.js6
2 files changed, 7 insertions, 3 deletions
diff --git a/README.md b/README.md
index 44a6749..769289d 100644
--- a/README.md
+++ b/README.md
@@ -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], ...
diff --git a/lsys.js b/lsys.js
index b102107..ffa4479 100644
--- a/lsys.js
+++ b/lsys.js
@@ -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() {