From c9027dfa2f903a9f041d4e2105bfee3a946617df Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Wed, 15 Apr 2020 10:01:35 +0800 Subject: [PATCH] add sierpinski_carpet --- examples/lsystem_collection.scad | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/lsystem_collection.scad b/examples/lsystem_collection.scad index ac7c0473..a733b922 100644 --- a/examples/lsystem_collection.scad +++ b/examples/lsystem_collection.scad @@ -1,7 +1,7 @@ use ; use ; -for(line = island_curve()) { +for(line = sierpinski_carpet()) { line2d( line[0], line[1], @@ -211,6 +211,16 @@ function sierpinski_square(n = 8, angle = 45, leng = 1, heading = 0, start = [0, ] ) lsystem2(axiom, rules, n, angle, leng, heading, start); + +function sierpinski_carpet(n = 4, angle = 90, leng = 1, heading = 0, start = [0, 0]) = + let( + axiom = "F", + rules = [ + ["F", "F+F-F-F-G+F+F+F-F"], + ["G", "GGG"] + ] + ) + lsystem2(axiom, rules, n, angle, leng, heading, start, forward_chars = "G"); function terdragon(n = 5, angle = 120, leng = 1, heading = 0, start = [0, 0]) = let(