-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid_array_cloner.scad
33 lines (30 loc) · 1.2 KB
/
grid_array_cloner.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use <../cloners.scad>
use <../random.scad>
// example 1
grid_array_cloner(size = [2, 2, 2], count = [3, 3, 3], clones = "random") {
color("Red") sphere(r = .5, center = true);
color("Yellow") cube([1, 1, 1], center = true);
color("Blue") cylinder(r = .5, h = 1, center = true);
}
translate([0, -2, 0]) linear_extrude(height = .1) text("example 1", size = .8);
// example 2
translate([10, 0, 0]) {
grid_array_cloner(size = [2, 2, 2], count = [3, 3, 3]) {
color(rand_color($i)) sphere(r = .5, center = true);
color(rand_color($i)) cube([1, 1, 1], center = true);
color(rand_color($i)) cylinder(r = .5, h = 1, center = true);
}
translate([0, -2, 0]) linear_extrude(height = .1) text("example 2", size = .8);
}
// example 3
translate([20, 0, 0]) {
grid_size = 3;
grid_array_cloner(size = [2, 2, 2], count = [grid_size, grid_size, grid_size]) {
rotate([
$i_xyz[0]/grid_size * -90,
$i_xyz[1]/grid_size * 90,
$i_xyz[2]/grid_size * -90
]) color([$i_xyz[0]/grid_size, .2, 0]) cylinder(r1 = .5, r2 = 0, h = 1, center = true);
}
translate([0, -2, 0]) linear_extrude(height = .1) text("example 3", size = .8);
}