1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-14 18:54:41 +02:00

support mask

This commit is contained in:
Justin Lin
2021-01-24 09:51:16 +08:00
parent 4101a347a0
commit d4362a8273

View File

@@ -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) ? [ edges = is_undef(seed) ? [
for(y = [0:rows]) 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; half_w = tile_width / 2;
translate([half_w, half_w]) translate([half_w, half_w])
for(y = [0:rows - 1]) { for(y = [0:rows - 1]) {
for(x = [0:columns - 1]) { for(x = [0:columns - 1]) {
i = (edges[y + 1][x][0] == 1 ? 1 : 0) + if(m[y][x] == 1) {
(edges[y][x + 1][1] == 1 ? 2 : 0) + i = (edges[y + 1][x][0] == 1 ? 1 : 0) +
(edges[y][x][0] == 1 ? 4 : 0) + (edges[y][x + 1][1] == 1 ? 2 : 0) +
(edges[y][x][1] == 1 ? 8 : 0); (edges[y][x][0] == 1 ? 4 : 0) +
translate([x, y] * tile_width) (edges[y][x][1] == 1 ? 8 : 0);
children(i); translate([x, y] * tile_width)
children(i);
}
} }
} }
} }