1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-20 05:21:38 +02:00

refactor: two dim maze

This commit is contained in:
Justin Lin
2022-03-27 11:39:52 +08:00
parent f34bfe1d90
commit a5408736e5

View File

@@ -13,14 +13,14 @@ use <../util/find_index.scad>;
function mz_squarewalls(cells, cell_width, left_border = true, bottom_border = true) =
let(
columns = find_index(cells, function(cell) cell.y != 0),
rows = len(cells) / columns,
rows = len(cells),
columns = len(cells[0]),
left_walls = left_border ? [for(y = [0:rows - 1]) [[0, cell_width * (y + 1)], [0, cell_width * y]]] : [],
buttom_walls = bottom_border ? [for(x = [0:columns - 1]) [[cell_width * x, 0], [cell_width * (x + 1), 0]]] : []
)
concat(
[
for(cell = cells)
for(row = cells, cell = row)
let(wall_pts = _square_walls(cell, cell_width))
if(wall_pts != [])
len(wall_pts) == 4 ? [wall_pts[0], wall_pts[1], wall_pts[3]]: wall_pts