1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
This commit is contained in:
Justin Lin 2022-04-23 16:29:50 +08:00
parent 1cfd8d5b11
commit bd0ee73350
5 changed files with 34 additions and 18 deletions

View File

@ -28,10 +28,14 @@ function _mz_mask(mask) =
columns = len(mask[0][1])
)
[
for(z = [0:layers - 1]) [
for(y = [0:rows - 1]) [
for(z = [0:layers - 1])
let(maze_z = mask[layers - z - 1])
[
for(y = [0:rows - 1])
let(maze_zy = maze_z[rows - y - 1])
[
for(x = [0:columns - 1])
mask[layers - z - 1][rows - y - 1][x] == 0 ?
maze_zy[x] == 0 ?
cell(
x, y, z,
MASK,

View File

@ -7,23 +7,27 @@ function tile_truchet(size, mask, seed) =
y_range = [0:rows - 1],
x_range = [0:columns - 1],
nums = [0, 1, 2, 3],
ones = [for(x = x_range) 1],
m = is_undef(mask) ? [
for(y = y_range)
[for(x = x_range) 1]
ones
] : [
for(y = rows - 1; y > -1; y = y - 1)
[for(x = x_range) mask[y][x]]
let(my = mask[y])
[for(x = x_range) my[x]]
]
)
is_undef(seed) ? [
for(y = y_range)
for(x = x_range)
if(m[y][x] == 1)
let(my = m[y])
for(x = x_range)
if(my[x] == 1)
[x, y, choose(nums)]
] : [
for(y = y_range)
for(y = y_range)
let(my = m[y])
for(x = x_range)
if(m[y][x] == 1)
[x, y, choose(nums, x + y * rows + seed)]
if(my[x] == 1)
[x, y, choose(nums, x + y * rows + seed)]
];

View File

@ -19,12 +19,14 @@ function tile_w2c(size, mask, seed) =
round(rands(0, 1, 1, seed + y * columns + x)[0])
]
],
ones = [for(x = x_range) 1],
m = is_undef(mask) ? [
for(y = y_range)
[for(x = x_range) 1]
ones
] : [
for(y = rows - 1; y > -1; y = y - 1)
[for(x = x_range) mask[y][x]]
let(my = mask[y])
[for(x = x_range) my[x]]
],
/*
8 1
@ -35,8 +37,9 @@ function tile_w2c(size, mask, seed) =
*/
tiles = [
for(y = y_range)
let(my = m[y])
for(x = x_range)
if(m[y][x] == 1)
if(my[x] == 1)
[x, y,
(corners[(y + 1) % rows][(x + 1) % columns] == 1 ? 1 : 0) +
(corners[y][(x + 1) % columns] == 1 ? 2 : 0) +

View File

@ -26,12 +26,14 @@ function tile_w2e(size, mask, seed) =
[round(rs[0]), round(rs[1])]
]
],
ones = [for(x = x_range) 1],
m = is_undef(mask) ? [
for(y = y_range)
[for(x = x_range) 1]
ones
] : [
for(y = rows - 1; y > -1; y = y - 1)
[for(x = x_range) mask[y][x]]
let(my = mask[y])
[for(x = x_range) my[x]]
],
/*
1
@ -42,8 +44,9 @@ function tile_w2e(size, mask, seed) =
*/
tiles = [
for(y = y_range)
let(my = m[y])
for(x = x_range)
if(m[y][x] == 1)
if(my[x] == 1)
[x, y,
(edges[(y + 1) % rows][x][0] == 1 ? 1 : 0) +
(edges[y][(x + 1) % columns][1] == 1 ? 2 : 0) +

View File

@ -22,9 +22,11 @@ function _mz_mask(mask) =
columns = len(mask[0])
)
[
for(y = [0:rows - 1]) [
for(y = [0:rows - 1])
let(mask_y = mask[rows - y - 1])
[
for(x = [0:columns - 1])
mask[rows - y - 1][x] == 0 ?
mask_y[x] == 0 ?
cell(
x, y,
MASK,