1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-14 10:44:48 +02:00

refactor: two dim cells

This commit is contained in:
Justin Lin
2022-03-27 11:59:00 +08:00
parent 53ac475bbf
commit a1a306995f

View File

@@ -11,20 +11,19 @@
use <../__comm__/_pt2_hash.scad>; use <../__comm__/_pt2_hash.scad>;
use <_impl/_mz_wang_tiles_impl.scad>; use <_impl/_mz_wang_tiles_impl.scad>;
use <mz_square_get.scad>; use <mz_square_get.scad>;
use <../util/find_index.scad>;
use <../util/sort.scad>; use <../util/sort.scad>;
use <../util/set/hashset.scad>; use <../util/set/hashset.scad>;
use <../util/set/hashset_elems.scad>; use <../util/set/hashset_elems.scad>;
function mz_wang_tiles(cells, left_border = true, bottom_border = true) = function mz_wang_tiles(cells, left_border = true, bottom_border = true) =
let( let(
columns = find_index(cells, function(cell) cell.y != 0), rows = len(cells),
rows = len(cells) / columns, columns = len(cells[0]),
top_cells = sort([for(cell = cells) if(cell.y == rows - 1) cell], by = "x"), top_cells = cells[rows - 1],
right_cells = sort([for(cell = cells) if(cell.x == columns - 1) cell], by = "y"), right_cells = [for(r = [0:rows - 1]) cells[r][columns - 1]],
all = concat( all = concat(
[ [
for(cell = cells) for(row = cells, cell = row)
let( let(
x = cell.x, x = cell.x,
y = cell.y, y = cell.y,