From e263daa376ed8b6be58d3c7d311e4b896666d8fc Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Thu, 27 Oct 2011 11:59:22 +0200 Subject: added lsys --- lsys/lsystem.js | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 lsys/lsystem.js (limited to 'lsys/lsystem.js') diff --git a/lsys/lsystem.js b/lsys/lsystem.js new file mode 100644 index 0000000..c3896e5 --- /dev/null +++ b/lsys/lsystem.js @@ -0,0 +1,172 @@ +/* LSystem */ + +function LSystem(axiom, ruleset) { + this.alphabet = ['F', '+', '-', '[', ']']; + this.axiom = axiom; + this.rule = ["", "+", "-", "[", "]"]; + this.tree = ""; + + this.rule[0] = ruleset; + + this.draw = function(x, y, zoom, angle, drawtype) { + a.fillStyle = "#000"; + a.strokeStyle = "#000"; + + a.save(); + a.translate(x, y); + + var i; + + for (i=0; i