From bf8cb445953f2149ef5e17f9a7ecbdd1c831c3a3 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Fri, 30 Jul 2021 11:43:31 +0800 Subject: [PATCH] rename param --- examples/tiles/2_corner_wang_tiles_basic.scad | 5 ++--- examples/tiles/2_edge_wang_tiles_basic.scad | 9 ++++----- examples/tiles/random_city.scad | 2 +- examples/tiles/random_town_square.scad | 9 ++++----- examples/tiles/tiles_wfc_tube.scad | 5 ++--- examples/tiles/tube_box.scad | 11 +++++------ src/experimental/tile_w2c.scad | 4 +++- src/experimental/tile_w2e.scad | 4 +++- src/experimental/tile_wfc.scad | 7 +++---- 9 files changed, 27 insertions(+), 29 deletions(-) diff --git a/examples/tiles/2_corner_wang_tiles_basic.scad b/examples/tiles/2_corner_wang_tiles_basic.scad index e311d572..4b667547 100644 --- a/examples/tiles/2_corner_wang_tiles_basic.scad +++ b/examples/tiles/2_corner_wang_tiles_basic.scad @@ -1,14 +1,13 @@ use ; use ; -rows = 10; -columns = 15; +size = [15, 10]; tile_width = 10; tile_thickness = 2; $fn = 24; translate([tile_width, tile_width] / 2) - for(tile = tile_w2c(rows, columns)) { + for(tile = tile_w2c(size)) { x = tile[0]; y = tile[1]; i = tile[2]; diff --git a/examples/tiles/2_edge_wang_tiles_basic.scad b/examples/tiles/2_edge_wang_tiles_basic.scad index 1fef3230..ed945ee1 100644 --- a/examples/tiles/2_edge_wang_tiles_basic.scad +++ b/examples/tiles/2_edge_wang_tiles_basic.scad @@ -1,14 +1,13 @@ use ; use ; -rows = 10; -columns = 15; +size = [15, 10]; tile_width = 10; tile_thickness = 2; $fn = 24; translate([tile_width, tile_width] / 2) - for(tile = tile_w2e(rows, columns)) { + for(tile = tile_w2e(size)) { x = tile[0]; y = tile[1]; i = tile[2]; @@ -16,9 +15,9 @@ translate([tile_width, tile_width] / 2) sample_tile(i, tile_width, tile_thickness); } -translate([0, tile_width * (rows + 1)] + [tile_width, tile_width] / 2) +translate([0, tile_width * (size[1] + 1)] + [tile_width, tile_width] / 2) color("green") - for(tile = tile_w2e(rows, columns)) { + for(tile = tile_w2e(size)) { x = tile[0]; y = tile[1]; i = tile[2]; diff --git a/examples/tiles/random_city.scad b/examples/tiles/random_city.scad index ac772a97..dd539cb3 100644 --- a/examples/tiles/random_city.scad +++ b/examples/tiles/random_city.scad @@ -29,7 +29,7 @@ module random_city(rows, columns, mask) { children(n); } - for(tile = tile_w2e(rows, columns, mask)) { + for(tile = tile_w2e([columns, rows], mask)) { x = tile[0]; y = tile[1]; i = tile[2]; diff --git a/examples/tiles/random_town_square.scad b/examples/tiles/random_town_square.scad index c4f84e49..f1053b7a 100644 --- a/examples/tiles/random_town_square.scad +++ b/examples/tiles/random_town_square.scad @@ -8,14 +8,13 @@ use ; use ; use ; -rows = 5; -columns = 5; +size = [5, 5]; tileW = 10; layerH = 1; -random_town_square(rows, columns, tileW, layerH); +random_town_square(size, tileW, layerH); -module random_town_square(rows, columns, tileW, layerH) { +module random_town_square(size, tileW, layerH) { sample = [ ["SS12", "CCRS1", "SS22", "CCRS0", "SS32", "F2", "SS14", "FW3", "SS04", "SS04"], ["SS12", "SS32", "F4", "SS12", "SS32", "F2", "SS14", "FW3", "SS24", "SS24"], @@ -31,7 +30,7 @@ module random_town_square(rows, columns, tileW, layerH) { ]; - generated = tile_wfc(rows, columns, sample); + generated = tile_wfc(size, sample); color("Gainsboro") draw_tiles(generated); diff --git a/examples/tiles/tiles_wfc_tube.scad b/examples/tiles/tiles_wfc_tube.scad index 7e410a07..3a0fd265 100644 --- a/examples/tiles/tiles_wfc_tube.scad +++ b/examples/tiles/tiles_wfc_tube.scad @@ -22,10 +22,9 @@ translate([-len(sample) * tileW, 0]) { draw_tubes(sample, tileW); } -width = 20; -height = 20; +size = [20, 20]; draw_tubes( - tile_wfc(width, height, sample), + tile_wfc(size, sample), tileW ); diff --git a/examples/tiles/tube_box.scad b/examples/tiles/tube_box.scad index 052e2381..2569239c 100644 --- a/examples/tiles/tube_box.scad +++ b/examples/tiles/tube_box.scad @@ -1,20 +1,19 @@ use ; use ; -rows = 8; -columns = 15; +size = [15, 8]; tile_width = 10; $fn = 12; -tube_box(rows, columns, tile_width); +tube_box(size, tile_width); -module tube_box(rows, columns, tile_width) { +module tube_box(size, tile_width) { half_w = tile_width / 2; quarter_w = tile_width / 4; eighth_w = tile_width / 8; translate([eighth_w, eighth_w, eighth_w] + [tile_width, tile_width, 0] / 2) - for(tile = tile_w2e(rows, columns)) { + for(tile = tile_w2e(size)) { x = tile[0]; y = tile[1]; i = tile[2]; @@ -23,7 +22,7 @@ module tube_box(rows, columns, tile_width) { } box_extrude(height = tile_width, shell_thickness = eighth_w) - square([columns * tile_width + quarter_w, rows * tile_width + quarter_w]); + square([size[0] * tile_width + quarter_w, size[1] * tile_width + quarter_w]); } module tube_tile(n, width) { diff --git a/src/experimental/tile_w2c.scad b/src/experimental/tile_w2c.scad index eb7897ea..c54a5798 100644 --- a/src/experimental/tile_w2c.scad +++ b/src/experimental/tile_w2c.scad @@ -1,7 +1,9 @@ // wang tiles - 2 corners -function tile_w2c(rows, columns, mask, seed) = +function tile_w2c(size, mask, seed) = let( + rows = size[1], + columns = size[0], y_range = [0:rows - 1], x_range = [0:columns - 1], corners = is_undef(seed) ? [ diff --git a/src/experimental/tile_w2e.scad b/src/experimental/tile_w2e.scad index c86b42b4..3f5b6743 100644 --- a/src/experimental/tile_w2e.scad +++ b/src/experimental/tile_w2e.scad @@ -1,7 +1,9 @@ // wang tiles - 2 edges -function tile_w2e(rows, columns, mask, seed) = +function tile_w2e(size, mask, seed) = let( + rows = size[1], + columns = size[0], y_range = [0:rows - 1], x_range = [0:columns - 1], /* diff --git a/src/experimental/tile_wfc.scad b/src/experimental/tile_wfc.scad index d7b2ae86..465755b7 100644 --- a/src/experimental/tile_wfc.scad +++ b/src/experimental/tile_wfc.scad @@ -1,8 +1,8 @@ use <_impl/_tiles_wfc_impl.scad>; // An implementation of [Wave Function Collapse](https://github.com/mxgmn/WaveFunctionCollapse) -function tile_wfc(width, height, sample) = - tilemap_generate(tilemap(width, height, sample)); +function tile_wfc(size, sample) = + tilemap_generate(tilemap(size[0], size[1], sample)); /* @@ -20,8 +20,7 @@ sample = [ ["S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S"] ]; -width = 20; -height = 20; +size = [20, 20]; echo(tile_wfc(width, height, sample)); */