mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-17 20:11:50 +02:00
refactor
This commit is contained in:
@@ -9,11 +9,12 @@
|
||||
**/
|
||||
|
||||
use <_impl/_mz_hex_walls.scad>;
|
||||
use <../util/find_index.scad>;
|
||||
|
||||
function mz_hexwalls(cells, cell_radius, left_border = true, bottom_border = true) =
|
||||
let(
|
||||
rows = len([for(cell = cells) if(cell.x == 0) undef]),
|
||||
columns = len([for(cell = cells) if(cell.y == 0) undef])
|
||||
columns = find_index(cells, function(cell) cell.y != 0),
|
||||
rows = len(cells) / columns
|
||||
)
|
||||
[
|
||||
each [for(cell = cells, wall = _build_cell(cell_radius, cell)) wall],
|
||||
|
@@ -10,13 +10,14 @@
|
||||
|
||||
use <_impl/_mz_square_cells_impl.scad>;
|
||||
use <mz_square_initialize.scad>;
|
||||
use <../util/find_index.scad>;
|
||||
|
||||
function mz_square_cells(rows, columns, start = [0, 0], init_cells, x_wrapping = false, y_wrapping = false, seed) =
|
||||
let(
|
||||
init_undef = is_undef(init_cells),
|
||||
mz = init_undef ? mz_square_initialize(rows, columns) : init_cells,
|
||||
r = len([for(cell = mz) if(cell.x == 0) undef]),
|
||||
c = len([for(cell = mz) if(cell.y == 0) undef])
|
||||
c = find_index(mz, function(cell) cell.y != 0),
|
||||
r = len(mz) / c
|
||||
)
|
||||
go_maze(
|
||||
start.x,
|
||||
|
@@ -9,11 +9,12 @@
|
||||
**/
|
||||
|
||||
use <_impl/_mz_square_walls_impl.scad>;
|
||||
use <../util/find_index.scad>;
|
||||
|
||||
function mz_squarewalls(cells, cell_width, left_border = true, bottom_border = true) =
|
||||
let(
|
||||
rows = len([for(cell = cells) if(cell.x == 0) undef]),
|
||||
columns = len([for(cell = cells) if(cell.y == 0) undef]),
|
||||
columns = find_index(cells, function(cell) cell.y != 0),
|
||||
rows = len(cells) / columns,
|
||||
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]]] : []
|
||||
)
|
||||
|
Reference in New Issue
Block a user