mirror of https://github.com/vitalif/openscad
minor cleanup
parent
4deb7b2d64
commit
ec0f42d648
|
@ -1,9 +1,24 @@
|
|||
echo(version=version());
|
||||
// children.scad - Usage of children()
|
||||
|
||||
// The use of children() allows to write generic modules that
|
||||
// modify child modules regardless of how the child geometry
|
||||
// is created.
|
||||
|
||||
color("red")
|
||||
make_ring_of(radius = 15, count = 6)
|
||||
cube(8, center = true);
|
||||
|
||||
color("green")
|
||||
make_ring_of(radius = 30, count = 12)
|
||||
difference() {
|
||||
sphere(5);
|
||||
cylinder(r = 2, h = 12, center = true);
|
||||
}
|
||||
|
||||
color("cyan")
|
||||
make_ring_of(radius = 50, count = 4)
|
||||
something();
|
||||
|
||||
module make_ring_of(radius, count)
|
||||
{
|
||||
for (a = [0 : count - 1]) {
|
||||
|
@ -26,23 +41,7 @@ module something()
|
|||
cube([22, 1.6, 0.4], center = true);
|
||||
}
|
||||
|
||||
color("red")
|
||||
make_ring_of(radius = 15, count = 6)
|
||||
cube(8, center = true);
|
||||
|
||||
color("green")
|
||||
make_ring_of(radius = 30, count = 12)
|
||||
difference() {
|
||||
sphere(5);
|
||||
cylinder(r = 2, h = 12, center = true);
|
||||
}
|
||||
|
||||
color("cyan")
|
||||
make_ring_of(radius = 50, count = 4)
|
||||
something();
|
||||
|
||||
|
||||
|
||||
echo(version=version());
|
||||
// Written in 2015 by Torsten Paul <Torsten.Paul@gmx.de>
|
||||
//
|
||||
// To the extent possible under law, the author(s) have dedicated all
|
||||
|
|
|
@ -1,26 +1,10 @@
|
|||
echo(version=version());
|
||||
// children_indexed.scad - Usage of indexed children()
|
||||
|
||||
// children() with a parameter allows access to a specific child
|
||||
// object with children(0) being the first one. In addition the
|
||||
// $children variable is automatically set to the number of child
|
||||
// objects.
|
||||
|
||||
module align_in_grid_and_add_text()
|
||||
{
|
||||
if ($children == 0) {
|
||||
text("Nothing...", 6, halign = "center");
|
||||
} else {
|
||||
t = $children == 1 ? "one object" : str($children, " objects ");
|
||||
text(t, 6, halign = "center");
|
||||
|
||||
for (y = [0 : $children - 1])
|
||||
for (x = [0 : $children - 1])
|
||||
translate([15 * (x - ($children - 1) / 2), 20 * y + 40, 0])
|
||||
scale(1 + x / $children)
|
||||
children(y);
|
||||
}
|
||||
}
|
||||
|
||||
color("red")
|
||||
translate([-100, -20, 0])
|
||||
align_in_grid_and_add_text();
|
||||
|
@ -47,7 +31,23 @@ color("green")
|
|||
}
|
||||
|
||||
|
||||
module align_in_grid_and_add_text()
|
||||
{
|
||||
if ($children == 0) {
|
||||
text("Nothing...", 6, halign = "center");
|
||||
} else {
|
||||
t = $children == 1 ? "one object" : str($children, " objects ");
|
||||
text(t, 6, halign = "center");
|
||||
|
||||
for (y = [0 : $children - 1])
|
||||
for (x = [0 : $children - 1])
|
||||
translate([15 * (x - ($children - 1) / 2), 20 * y + 40, 0])
|
||||
scale(1 + x / $children)
|
||||
children(y);
|
||||
}
|
||||
}
|
||||
|
||||
echo(version=version());
|
||||
// Written in 2015 by Torsten Paul <Torsten.Paul@gmx.de>
|
||||
//
|
||||
// To the extent possible under law, the author(s) have dedicated all
|
||||
|
|
Loading…
Reference in New Issue