From cf61c25302bb3c8fcd110dfdc48d2b065ee74f63 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Wed, 15 Apr 2020 16:21:14 +0800 Subject: [PATCH] add fern --- examples/lsystem2_collection.scad | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/lsystem2_collection.scad b/examples/lsystem2_collection.scad index e6129d1f..2276ca45 100644 --- a/examples/lsystem2_collection.scad +++ b/examples/lsystem2_collection.scad @@ -1,7 +1,7 @@ use ; use ; -for(line = tree()) { +for(line = fern()) { line2d( line[0], line[1], @@ -11,6 +11,17 @@ for(line = tree()) { ); } +function fern(n = 8, angle = 4, leng = 1, heading = 0, start = [0, 0]) = + let( + axiom = "EEEA", + rules = [ + ["A", "[++++++++++++++EC]B+B[--------------ED]B+BA"], + ["C", "[---------EE][+++++++++EE]B+C"], + ["D", "[---------EE][+++++++++EE]B-D"] + ] + ) + lsystem2(axiom, rules, n, angle, leng, heading, start, forward_chars = "ABCDE"); + function tree(n = 2, angle = 36, leng = 1, heading = 0, start = [0, 0]) = let( axiom = "F",