1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-21 14:04:53 +02:00

add mz_initialize

This commit is contained in:
Justin Lin
2020-11-18 17:37:24 +08:00
parent 37c72df265
commit e3ac8d6ba0
2 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
use <_mz_comm.scad>;
// create a starting maze for being visited later.
function _rc_maze(rows, columns) = [
for(y = [1:rows])
for(x = [1:columns])
block(
x, y,
// all blocks have top and right walls
3,
// unvisited
false
)
];
function _mz_mask(mask) =
let(
rows = len(mask),
columns = len(mask[0])
)
[
for(y = [1:rows])
for(x = [1:columns])
mask[rows - y][x - 1] == 0 ?
block(
x, y,
4, // mask
true // visited
)
:
block(
x, y,
// all blocks have top and right walls
3,
// unvisited
false
)
];

View File

@@ -0,0 +1,4 @@
use <_impl/_mz_initialize.scad>;
function mz_initialize(row, columns, mask) =
is_undef(mask) ? _rc_maze(rows, columns) : _mz_mask(mask);