diff --git a/examples/tiles/2_corner_wang_tiles_basic.scad b/examples/tiles/2_corner_wang_tiles_basic.scad index de65ec0a..4b667547 100644 --- a/examples/tiles/2_corner_wang_tiles_basic.scad +++ b/examples/tiles/2_corner_wang_tiles_basic.scad @@ -1,6 +1,5 @@ use ; use ; -use ; size = [15, 10]; tile_width = 10; diff --git a/examples/tiles/2_edge_wang_tiles_basic.scad b/examples/tiles/2_edge_wang_tiles_basic.scad index bb9dc000..30e28053 100644 --- a/examples/tiles/2_edge_wang_tiles_basic.scad +++ b/examples/tiles/2_edge_wang_tiles_basic.scad @@ -1,5 +1,5 @@ use ; -use ; +use ; use ; size = [15, 10]; @@ -125,7 +125,7 @@ module path_tile(n, width) { } } - choose_children(n) { + select(n) { square(width, center = true); tile1(); rotate(-90) tile1(); diff --git a/examples/tiles/hitomezashi_stitching.scad b/examples/tiles/hitomezashi_stitching.scad index 2157f74b..e0358f4f 100644 --- a/examples/tiles/hitomezashi_stitching.scad +++ b/examples/tiles/hitomezashi_stitching.scad @@ -1,6 +1,6 @@ use ; use ; -use ; +use ; size = [50, 25]; tile_width = 5; @@ -10,7 +10,9 @@ for(tile = tile_hitomezashi(size)) { x = tile[0]; y = tile[1]; i = tile[2]; - choose_children(i) { + + translate([x, y] * tile_width) + select(i) { tile00(x, y, tile_width, line_width); tile01(x, y, tile_width, line_width); tile02(x, y, tile_width, line_width); @@ -24,20 +26,16 @@ module tile00(x, y, tile_width, line_width) { // _ module tile01(x, y, tile_width, line_width) { - translate([x, y] * tile_width) - line2d([0, 0], [tile_width, 0], line_width); + line2d([0, 0], [tile_width, 0], line_width); } // |_ module tile02(x, y, tile_width, line_width) { - translate([x, y] * tile_width) - line2d([0, 0], [0, tile_width], line_width); + line2d([0, 0], [0, tile_width], line_width); } // | module tile03(x, y, tile_width, line_width) { - translate([x, y] * tile_width) { - line2d([0, 0], [0, tile_width], line_width); - line2d([0, 0], [tile_width, 0], line_width); - } + line2d([0, 0], [0, tile_width], line_width); + line2d([0, 0], [tile_width, 0], line_width); } \ No newline at end of file diff --git a/examples/tiles/knot_tiles.scad b/examples/tiles/knot_tiles.scad index ff55a062..a8069df5 100644 --- a/examples/tiles/knot_tiles.scad +++ b/examples/tiles/knot_tiles.scad @@ -1,7 +1,7 @@ use ; use ; use ; -use ; +use ; size = [50, 25]; tile_width = 5; @@ -14,7 +14,8 @@ for(tile = tile_truchet(size)) { y = tile[1]; i = tile[2]; - choose_children(i) { + translate([x, y] * tile_width) + select(i) { tile00(x, y, tile_width, line_width); tile01(x, y, tile_width, line_width); tile02(x, y, tile_width, line_width); @@ -23,33 +24,28 @@ for(tile = tile_truchet(size)) { } module tile00(x, y, tile_width, line_width) { - translate([x, y] * tile_width) - arc(0.5 * tile_width, [0, 90], line_width); - translate([x + 1, y + 1] * tile_width) + arc(0.5 * tile_width, [0, 90], line_width); + translate([tile_width, tile_width]) arc(0.5 * tile_width, [180, 270], line_width); } module tile01(x, y, tile_width, line_width) { - translate([x, y + 1] * tile_width) + translate([0, tile_width]) arc(0.5 * tile_width, [270, 360], line_width); - translate([x + 1, y] * tile_width) + translate([tile_width, 0]) arc(0.5 * tile_width, [90, 180], line_width); } module tile02(x, y, tile_width, line_width) { half_width = tile_width * 0.5; - translate([x, y] * tile_width) { - line2d([half_width, 0], [half_width, tile_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); - line2d([0, half_width], [half_width - line_width, half_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); - line2d([half_width + line_width, half_width], [tile_width, half_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); - } + line2d([half_width, 0], [half_width, tile_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); + line2d([0, half_width], [half_width - line_width, half_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); + line2d([half_width + line_width, half_width], [tile_width, half_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); } module tile03(x, y, tile_width, line_width) { half_width = tile_width * 0.5; - translate([x, y] * tile_width) { - line2d([0, half_width], [tile_width, half_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); - line2d([half_width, 0], [half_width, half_width - line_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); - line2d([half_width, tile_width], [half_width, half_width + line_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); - } + line2d([0, half_width], [tile_width, half_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); + line2d([half_width, 0], [half_width, half_width - line_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); + line2d([half_width, tile_width], [half_width, half_width + line_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT"); } \ No newline at end of file diff --git a/examples/tiles/random_city.scad b/examples/tiles/random_city.scad index d804b84e..27dc6042 100644 --- a/examples/tiles/random_city.scad +++ b/examples/tiles/random_city.scad @@ -4,7 +4,7 @@ use ; use ; use ; use ; -use ; +use ; mask = [ [0, 1, 1, 0, 0, 0, 1, 1, 0], @@ -31,7 +31,7 @@ module random_city(rows, columns, mask) { y = tile[1]; i = tile[2]; translate([x, y] * tile_width) - choose_children(i) { + select(i) { tile00(); tile01(); tile02(); diff --git a/examples/tiles/tube_box.scad b/examples/tiles/tube_box.scad index fb4bfbb9..65e086d5 100644 --- a/examples/tiles/tube_box.scad +++ b/examples/tiles/tube_box.scad @@ -1,5 +1,5 @@ use ; -use ; +use ; use ; size = [15, 8]; @@ -112,7 +112,7 @@ module tube_tile(n, width) { tile5(); } - choose_children(n) { + select(n) { tile0(); tile1(); rotate(-90) tile1(); diff --git a/src/experimental/choose_children.scad b/src/experimental/choose_children.scad deleted file mode 100644 index 5d138adb..00000000 --- a/src/experimental/choose_children.scad +++ /dev/null @@ -1,3 +0,0 @@ -module choose_children(n) { - children(n); -} \ No newline at end of file diff --git a/src/experimental/select.scad b/src/experimental/select.scad new file mode 100644 index 00000000..f149a6c9 --- /dev/null +++ b/src/experimental/select.scad @@ -0,0 +1,3 @@ +module select(n) { + children(n); +} \ No newline at end of file