From 97663dd6a3e7687b23d66f872673c69318a82880 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Mon, 9 Mar 2020 21:16:26 -0700 Subject: [PATCH] Fixed fractal_tree.scad for attachable() refactoring. --- examples/fractal_tree.scad | 29 ++++++++++++++++++----------- version.scad | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/examples/fractal_tree.scad b/examples/fractal_tree.scad index c367a76..0cb34c2 100644 --- a/examples/fractal_tree.scad +++ b/examples/fractal_tree.scad @@ -15,27 +15,34 @@ module leaf(s) { ); } -module branches(minsize){ - if($parent_size2.x>minsize) { +module branches(minsize, s1, s2){ + if(s2>minsize) { attach(TOP) zrot(gaussian_rands(90,20)[0]) zrot_copies(n=floor(log_rands(2,5,4)[0])) zrot(gaussian_rands(0,5)[0]) - yrot(gaussian_rands(30,10)[0]) - let( - sc = gaussian_rands(0.7,0.05)[0], - s1 = $parent_size.z*sc, - s2 = $parent_size2.x - ) - cylinder(d1=s2, d2=s2*sc, l=s1) - branches(minsize); + yrot(gaussian_rands(30,10)[0]) { + sc = gaussian_rands(0.7,0.05)[0]; + cylinder(d1=s2, d2=s2*sc, l=s1) + branches(minsize, s1*sc, s2*sc); + } } else { recolor("springgreen") attach(TOP) zrot(90) leaf(gaussian_rands(100,5)[0]); } } -recolor("lightgray") cylinder(d1=300, d2=250, l=1500) branches(10); + +module tree(h, d, minsize) { + sc = gaussian_rands(0.7,0.05)[0]; + recolor("lightgray") { + cylinder(d1=d, d2=d*sc, l=h) { + branches(minsize, h, d*sc); + } + } +} + +tree(d=300, h=1500, minsize=10); // vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/version.scad b/version.scad index dca8fa0..276e940 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,177]; +BOSL_VERSION = [2,0,178]; // Section: BOSL Library Version Functions