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