mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-15 03:05:41 +02:00
support mask
This commit is contained in:
@@ -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,10 +15,19 @@ 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]) {
|
||||||
|
if(m[y][x] == 1) {
|
||||||
i = (edges[y + 1][x][0] == 1 ? 1 : 0) +
|
i = (edges[y + 1][x][0] == 1 ? 1 : 0) +
|
||||||
(edges[y][x + 1][1] == 1 ? 2 : 0) +
|
(edges[y][x + 1][1] == 1 ? 2 : 0) +
|
||||||
(edges[y][x][0] == 1 ? 4 : 0) +
|
(edges[y][x][0] == 1 ? 4 : 0) +
|
||||||
@@ -27,4 +36,5 @@ module 2_edge_wang_tiles(rows, columns, tile_width, seed) {
|
|||||||
children(i);
|
children(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user