1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-13 18:24:28 +02:00

rename param

This commit is contained in:
Justin Lin
2021-07-30 11:43:31 +08:00
parent 6e3d3e0a4b
commit bf8cb44595
9 changed files with 27 additions and 29 deletions

View File

@@ -1,14 +1,13 @@
use <experimental/tile_w2c.scad>; use <experimental/tile_w2c.scad>;
use <arc.scad>; use <arc.scad>;
rows = 10; size = [15, 10];
columns = 15;
tile_width = 10; tile_width = 10;
tile_thickness = 2; tile_thickness = 2;
$fn = 24; $fn = 24;
translate([tile_width, tile_width] / 2) translate([tile_width, tile_width] / 2)
for(tile = tile_w2c(rows, columns)) { for(tile = tile_w2c(size)) {
x = tile[0]; x = tile[0];
y = tile[1]; y = tile[1];
i = tile[2]; i = tile[2];

View File

@@ -1,14 +1,13 @@
use <experimental/tile_w2e.scad>; use <experimental/tile_w2e.scad>;
use <arc.scad>; use <arc.scad>;
rows = 10; size = [15, 10];
columns = 15;
tile_width = 10; tile_width = 10;
tile_thickness = 2; tile_thickness = 2;
$fn = 24; $fn = 24;
translate([tile_width, tile_width] / 2) translate([tile_width, tile_width] / 2)
for(tile = tile_w2e(rows, columns)) { for(tile = tile_w2e(size)) {
x = tile[0]; x = tile[0];
y = tile[1]; y = tile[1];
i = tile[2]; i = tile[2];
@@ -16,9 +15,9 @@ translate([tile_width, tile_width] / 2)
sample_tile(i, tile_width, tile_thickness); 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") color("green")
for(tile = tile_w2e(rows, columns)) { for(tile = tile_w2e(size)) {
x = tile[0]; x = tile[0];
y = tile[1]; y = tile[1];
i = tile[2]; i = tile[2];

View File

@@ -29,7 +29,7 @@ module random_city(rows, columns, mask) {
children(n); children(n);
} }
for(tile = tile_w2e(rows, columns, mask)) { for(tile = tile_w2e([columns, rows], mask)) {
x = tile[0]; x = tile[0];
y = tile[1]; y = tile[1];
i = tile[2]; i = tile[2];

View File

@@ -8,14 +8,13 @@ use <rounded_square.scad>;
use <box_extrude.scad>; use <box_extrude.scad>;
use <polyhedron_hull.scad>; use <polyhedron_hull.scad>;
rows = 5; size = [5, 5];
columns = 5;
tileW = 10; tileW = 10;
layerH = 1; 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 = [ sample = [
["SS12", "CCRS1", "SS22", "CCRS0", "SS32", "F2", "SS14", "FW3", "SS04", "SS04"], ["SS12", "CCRS1", "SS22", "CCRS0", "SS32", "F2", "SS14", "FW3", "SS04", "SS04"],
["SS12", "SS32", "F4", "SS12", "SS32", "F2", "SS14", "FW3", "SS24", "SS24"], ["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") color("Gainsboro")
draw_tiles(generated); draw_tiles(generated);

View File

@@ -22,10 +22,9 @@ translate([-len(sample) * tileW, 0]) {
draw_tubes(sample, tileW); draw_tubes(sample, tileW);
} }
width = 20; size = [20, 20];
height = 20;
draw_tubes( draw_tubes(
tile_wfc(width, height, sample), tile_wfc(size, sample),
tileW tileW
); );

View File

@@ -1,20 +1,19 @@
use <experimental/tile_w2e.scad>; use <experimental/tile_w2e.scad>;
use <box_extrude.scad>; use <box_extrude.scad>;
rows = 8; size = [15, 8];
columns = 15;
tile_width = 10; tile_width = 10;
$fn = 12; $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; half_w = tile_width / 2;
quarter_w = tile_width / 4; quarter_w = tile_width / 4;
eighth_w = tile_width / 8; eighth_w = tile_width / 8;
translate([eighth_w, eighth_w, eighth_w] + [tile_width, tile_width, 0] / 2) 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]; x = tile[0];
y = tile[1]; y = tile[1];
i = tile[2]; i = tile[2];
@@ -23,7 +22,7 @@ module tube_box(rows, columns, tile_width) {
} }
box_extrude(height = tile_width, shell_thickness = eighth_w) 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) { module tube_tile(n, width) {

View File

@@ -1,7 +1,9 @@
// wang tiles - 2 corners // wang tiles - 2 corners
function tile_w2c(rows, columns, mask, seed) = function tile_w2c(size, mask, seed) =
let( let(
rows = size[1],
columns = size[0],
y_range = [0:rows - 1], y_range = [0:rows - 1],
x_range = [0:columns - 1], x_range = [0:columns - 1],
corners = is_undef(seed) ? [ corners = is_undef(seed) ? [

View File

@@ -1,7 +1,9 @@
// wang tiles - 2 edges // wang tiles - 2 edges
function tile_w2e(rows, columns, mask, seed) = function tile_w2e(size, mask, seed) =
let( let(
rows = size[1],
columns = size[0],
y_range = [0:rows - 1], y_range = [0:rows - 1],
x_range = [0:columns - 1], x_range = [0:columns - 1],
/* /*

View File

@@ -1,8 +1,8 @@
use <_impl/_tiles_wfc_impl.scad>; use <_impl/_tiles_wfc_impl.scad>;
// An implementation of [Wave Function Collapse](https://github.com/mxgmn/WaveFunctionCollapse) // An implementation of [Wave Function Collapse](https://github.com/mxgmn/WaveFunctionCollapse)
function tile_wfc(width, height, sample) = function tile_wfc(size, sample) =
tilemap_generate(tilemap(width, height, 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"] ["S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S", "S"]
]; ];
width = 20; size = [20, 20];
height = 20;
echo(tile_wfc(width, height, sample)); echo(tile_wfc(width, height, sample));
*/ */