mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-14 02:34:12 +02:00
refactor
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use <_mz_square_comm.scad>;
|
use <_mz_square_comm.scad>;
|
||||||
|
|
||||||
function eqPos(x, y, cell) = get_x(cell) == x && get_y(cell) == y;
|
function eqPos(x, y, cell) = cell.x == x && cell.y == y;
|
||||||
|
|
||||||
// is (x, y) visited?
|
// is (x, y) visited?
|
||||||
function visited(x, y, cells, columns) = cells[y * columns + x][3];
|
function visited(x, y, cells, columns) = cells[y * columns + x][3];
|
||||||
|
@@ -10,6 +10,6 @@ function right_wall(cell) = get_type(cell) == 2;
|
|||||||
function top_right_wall(cell) = get_type(cell) == 3;
|
function top_right_wall(cell) = get_type(cell) == 3;
|
||||||
|
|
||||||
function cell(x, y, type, visited) = [x, y, type, visited];
|
function cell(x, y, type, visited) = [x, y, type, visited];
|
||||||
function get_x(cell) = cell[0];
|
function get_x(cell) = cell.x;
|
||||||
function get_y(cell) = cell[1];
|
function get_y(cell) = cell.y;
|
||||||
function get_type(cell) = cell[2];
|
function get_type(cell) = cell[2];
|
@@ -1,7 +1,7 @@
|
|||||||
use <_mz_square_comm.scad>;
|
use <_mz_square_comm.scad>;
|
||||||
|
|
||||||
function _square_walls(cell, cell_width) =
|
function _square_walls(cell, cell_width) =
|
||||||
let(loc = [get_x(cell), get_y(cell)] * cell_width)
|
let(loc = [cell.x, cell.y] * cell_width)
|
||||||
[
|
[
|
||||||
if(top_wall(cell) || top_right_wall(cell)) each [[0, cell_width] + loc, [cell_width, cell_width] + loc],
|
if(top_wall(cell) || top_right_wall(cell)) each [[0, cell_width] + loc, [cell_width, cell_width] + loc],
|
||||||
if(right_wall(cell) || top_right_wall(cell)) each [[cell_width, cell_width] + loc, [cell_width, 0] + loc]
|
if(right_wall(cell) || top_right_wall(cell)) each [[cell_width, cell_width] + loc, [cell_width, 0] + loc]
|
||||||
|
@@ -24,8 +24,8 @@ function mz_hamiltonian(rows, columns, start = [0, 0], seed) =
|
|||||||
[
|
[
|
||||||
for(cell = cells)
|
for(cell = cells)
|
||||||
let(
|
let(
|
||||||
x = mz_square_get(cell, "x"),
|
x = cell.x,
|
||||||
y = mz_square_get(cell, "y"),
|
y = cell.y,
|
||||||
type = mz_square_get(cell, "t")
|
type = mz_square_get(cell, "t")
|
||||||
)
|
)
|
||||||
each if(type == "TOP_WALL") _mz_hamiltonian_top(x, y) else
|
each if(type == "TOP_WALL") _mz_hamiltonian_top(x, y) else
|
||||||
|
@@ -25,8 +25,8 @@ function mz_wang_tiles(rows, columns, start = [0, 0], init_cells, seed) =
|
|||||||
[
|
[
|
||||||
for(cell = cells)
|
for(cell = cells)
|
||||||
let(
|
let(
|
||||||
x = mz_square_get(cell, "x"),
|
x = cell.x,
|
||||||
y = mz_square_get(cell, "y"),
|
y = cell.y,
|
||||||
type = mz_square_get(cell, "t"),
|
type = mz_square_get(cell, "t"),
|
||||||
pts = type == "TOP_WALL" ? _mz_wang_tiles_top(x, y) :
|
pts = type == "TOP_WALL" ? _mz_wang_tiles_top(x, y) :
|
||||||
type == "RIGHT_WALL" ? _mz_wang_tiles_right(x, y) :
|
type == "RIGHT_WALL" ? _mz_wang_tiles_right(x, y) :
|
||||||
|
Reference in New Issue
Block a user