diff options
author | Marius Kintel <marius@kintel.net> | 2013-04-09 04:28:16 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-04-09 04:28:16 (GMT) |
commit | a37813a8999571f4b9235f33fdc7c22bcbe5fd17 (patch) | |
tree | 266d8c106100edab9f51b93cf229cf55cd083918 /testdata/scad/features/module-recursion.scad | |
parent | b16c24fb2888d932ec035fff27cb29b4ffbc256b (diff) |
Refactored context handling into using separate Module contexts and Eval contexts. This allows for recursive module calls, and cascading children. I believe this fixes issue #116
Diffstat (limited to 'testdata/scad/features/module-recursion.scad')
-rw-r--r-- | testdata/scad/features/module-recursion.scad | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/testdata/scad/features/module-recursion.scad b/testdata/scad/features/module-recursion.scad new file mode 100644 index 0000000..f67a1d0 --- /dev/null +++ b/testdata/scad/features/module-recursion.scad @@ -0,0 +1,15 @@ +module tree(currentScale, levels) +{ + h = currentScale; + w = currentScale/5; + childScale = currentScale * 0.7; + + if (levels > 0) { + cylinder(r=w, h=h); + translate([0,0,h]) for (i = [1:2]) { + rotate([40, 0, i * 180]) tree(childScale, levels-1); + } + } +} + +tree(1, 4); |