1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-17 20:11:50 +02:00

add mz_squarewalls

This commit is contained in:
Justin Lin
2022-03-16 08:25:01 +08:00
parent aa70a75fa2
commit 0280293192
2 changed files with 30 additions and 1 deletions

View File

@@ -9,4 +9,5 @@ new:
- noise/worley_sphere?
- voronoi/vrn_sphere?
- t3d - roll/pitch/forward
- polyline_join: doc multi-childs
- polyline_join: doc multi-childs
- mz_squarewalls

View File

@@ -0,0 +1,28 @@
/**
* mz_square_walls.scad
*
* @copyright Justin Lin, 2020
* @license https://opensource.org/licenses/lgpl-3.0.html
*
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-mz_square_walls.html
*
**/
use <_impl/_mz_square_walls_impl.scad>;
function mz_squarewalls(cells, cell_width, left_border = true, bottom_border = true) =
let(
rows = len([for(cell = cells) if(cell.y == 0) undef]),
columns = len(cells) - rows,
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)
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
]
, left_walls, buttom_walls
);