diff --git a/src/experimental/2_edge_wang_tiles.scad b/src/experimental/2_edge_wang_tiles.scad index 1327a9c3..3bc12fb4 100644 --- a/src/experimental/2_edge_wang_tiles.scad +++ b/src/experimental/2_edge_wang_tiles.scad @@ -1,4 +1,4 @@ -module 2_edge_wang_tiles(rows, columns, tile_width, seed) { +module 2_edge_wang_tiles(rows, columns, tile_width, mask, seed) { edges = is_undef(seed) ? [ for(y = [0:rows]) [ @@ -15,16 +15,26 @@ module 2_edge_wang_tiles(rows, columns, tile_width, seed) { ] ]; + m = is_undef(mask) ? [ + for(y = [0:rows - 1]) + [for(x = [0:columns - 1]) 1] + ] : [ + for(y = rows - 1; y > -1; y = y - 1) + [for(x = [0:columns - 1]) mask[y][x]] + ]; + half_w = tile_width / 2; translate([half_w, half_w]) for(y = [0:rows - 1]) { for(x = [0:columns - 1]) { - i = (edges[y + 1][x][0] == 1 ? 1 : 0) + - (edges[y][x + 1][1] == 1 ? 2 : 0) + - (edges[y][x][0] == 1 ? 4 : 0) + - (edges[y][x][1] == 1 ? 8 : 0); - translate([x, y] * tile_width) - children(i); + if(m[y][x] == 1) { + i = (edges[y + 1][x][0] == 1 ? 1 : 0) + + (edges[y][x + 1][1] == 1 ? 2 : 0) + + (edges[y][x][0] == 1 ? 4 : 0) + + (edges[y][x][1] == 1 ? 8 : 0); + translate([x, y] * tile_width) + children(i); + } } } } \ No newline at end of file