diff --git a/examples/tiles/2_edge_wang_tiles_basic.scad b/examples/tiles/2_edge_wang_tiles_basic.scad index 5dc6199f..1fef3230 100644 --- a/examples/tiles/2_edge_wang_tiles_basic.scad +++ b/examples/tiles/2_edge_wang_tiles_basic.scad @@ -124,53 +124,27 @@ module path_tile(n, width) { } } } - - if(n == 0) { - square(width, center = true); + + module select_child(n) { + children(n); } - else if(n == 1) { + + select_child(n) { + square(width, center = true); tile1(); - } - else if(n == 2) { - rotate(-90) tile1(); - } - else if(n == 3) { - tile3(); - } - else if(n == 4) { - rotate(-180) tile1(); - } - else if(n == 5) { - tile5(); - } - else if(n == 6) { - rotate(-90) tile3(); - } - else if(n == 7) { - tile7(); - } - else if(n == 8) { - rotate(90) tile1(); - } - else if(n == 9) { - rotate(90) tile3(); - } - else if(n == 10) { - rotate(90) tile5(); - } - else if(n == 11) { - rotate(90) tile7(); - } - else if(n == 12) { - rotate(-180) tile3(); - } - else if(n == 13) { - rotate(180) tile7(); - } - else if(n == 14) { - rotate(270) tile7(); - } - else if(n == 15) { - tile15(); + rotate(-90) tile1(); + tile3(); + rotate(-180) tile1(); + tile5(); + rotate(-90) tile3(); + tile7(); + rotate(90) tile1(); + rotate(90) tile3(); + rotate(90) tile5(); + rotate(90) tile7(); + rotate(-180) tile3(); + rotate(180) tile7(); + rotate(270) tile7(); + tile15(); } } \ No newline at end of file diff --git a/examples/tiles/random_city.scad b/examples/tiles/random_city.scad index 912e7526..ac772a97 100644 --- a/examples/tiles/random_city.scad +++ b/examples/tiles/random_city.scad @@ -25,33 +25,33 @@ random_city(rows, columns, mask); module random_city(rows, columns, mask) { tile_width = 30; - module tiles() { - for(tile = tile_w2e(rows, columns, mask)) { - x = tile[0]; - y = tile[1]; - i = tile[2]; - translate([x, y] * tile_width) - children(i); - } - } + module select_child(n) { + children(n); + } - tiles() { - tile00(); - tile01(); - tile02(); - tile03(); - tile04(); - tile05(); - tile06(); - tile07(); - tile08(); - tile09(); - tile10(); - tile11(); - tile12(); - tile13(); - tile14(); - tile15(); + for(tile = tile_w2e(rows, columns, mask)) { + x = tile[0]; + y = tile[1]; + i = tile[2]; + translate([x, y] * tile_width) + select_child(i) { + tile00(); + tile01(); + tile02(); + tile03(); + tile04(); + tile05(); + tile06(); + tile07(); + tile08(); + tile09(); + tile10(); + tile11(); + tile12(); + tile13(); + tile14(); + tile15(); + } } // tiles, quick and dirty code diff --git a/examples/tiles/tube_box.scad b/examples/tiles/tube_box.scad index 8fbfb528..052e2381 100644 --- a/examples/tiles/tube_box.scad +++ b/examples/tiles/tube_box.scad @@ -13,7 +13,7 @@ module tube_box(rows, columns, tile_width) { quarter_w = tile_width / 4; eighth_w = tile_width / 8; - translate([eighth_w, eighth_w, -eighth_w] + [tile_width, tile_width] / 2) + translate([eighth_w, eighth_w, eighth_w] + [tile_width, tile_width, 0] / 2) for(tile = tile_w2e(rows, columns)) { x = tile[0]; y = tile[1]; @@ -30,6 +30,26 @@ module tube_tile(n, width) { half_w = width / 2; quarter_w = width / 4; sixteenth_w = width / 16; + + module tile0() { + difference() { + union() { + linear_extrude(width / 2) + circle(quarter_w); + + translate([0, 0, half_w]) + linear_extrude(sixteenth_w, center = true) + circle(quarter_w * 1.2); + + linear_extrude(sixteenth_w, center = true) + circle(quarter_w * 1.2); + } + + linear_extrude(width) + circle(quarter_w - quarter_w * 0.2); + } + } + module tile1() { translate([0, half_w]) rotate([90, 0, -90]) { @@ -91,53 +111,27 @@ module tube_tile(n, width) { rotate(90) tile5(); } - - if(n == 0) { - // no tube - } - else if(n == 1) { + + module select_child(n) { + children(n); + } + + select_child(n) { + tile0(); tile1(); - } - else if(n == 2) { - rotate(-90) tile1(); - } - else if(n == 3) { - tile3(); - } - else if(n == 4) { - rotate(-180) tile1(); - } - else if(n == 5) { - tile5(); - } - else if(n == 6) { - rotate(-90) tile3(); - } - else if(n == 7) { - tile7(); - } - else if(n == 8) { - rotate(90) tile1(); - } - else if(n == 9) { - rotate(90) tile3(); - } - else if(n == 10) { - rotate(90) tile5(); - } - else if(n == 11) { - rotate(90) tile7(); - } - else if(n == 12) { - rotate(-180) tile3(); - } - else if(n == 13) { - rotate(180) tile7(); - } - else if(n == 14) { - rotate(270) tile7(); - } - else if(n == 15) { - tile15(); + rotate(-90) tile1(); + tile3(); + rotate(-180) tile1(); + tile5(); + rotate(-90) tile3(); + tile7(); + rotate(90) tile1(); + rotate(90) tile3(); + rotate(90) tile5(); + rotate(90) tile7(); + rotate(-180) tile3(); + rotate(180) tile7(); + rotate(270) tile7(); + tile15(); } } \ No newline at end of file