1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-11 09:14:29 +02:00
This commit is contained in:
Justin Lin
2021-01-16 18:36:13 +08:00
parent 1da33fd933
commit 6d375e6480
2 changed files with 22 additions and 22 deletions

View File

@@ -1,3 +1,4 @@
use <experimental/2_edge_wang_tiles.scad>;
use <box_extrude.scad>; use <box_extrude.scad>;
rows = 8; rows = 8;
@@ -12,7 +13,7 @@ module tube_box(rows, columns, tile_width) {
quarter_w = tile_width / 4; quarter_w = tile_width / 4;
eighth_w = tile_width / 8; eighth_w = tile_width / 8;
two_edge_wang_tiles(rows, columns, tile_width) { 2_edge_wang_tiles(rows, columns, tile_width) {
tube_tile(0, tile_width); tube_tile(0, tile_width);
tube_tile(1, tile_width); tube_tile(1, tile_width);
tube_tile(2, tile_width); tube_tile(2, tile_width);
@@ -36,27 +37,6 @@ module tube_box(rows, columns, tile_width) {
square([columns * tile_width + quarter_w, rows * tile_width + quarter_w]); square([columns * tile_width + quarter_w, rows * tile_width + quarter_w]);
} }
module two_edge_wang_tiles(rows, columns, tile_width) {
edges = [
for(y = [0:rows])
[
for(x = [0:columns])
[round(rands(0, 1, 1)[0]), round(rands(0, 1, 1)[0])]
]
];
for(y = [0:rows - 1]) {
for(x = [0:columns - 1]) {
i = (edges[y + 1][x][0] == 1 ? 1 : 0) +
(edges[y][x + 1][1] == 1 ? 2 : 0) +
(edges[y][x][0] == 1 ? 4 : 0) +
(edges[y][x][1] == 1 ? 8 : 0);
translate([x, y] * tile_width)
children(i);
}
}
}
module tube_tile(n, width) { module tube_tile(n, width) {
half_w = width / 2; half_w = width / 2;
quarter_w = width / 4; quarter_w = width / 4;

View File

@@ -0,0 +1,20 @@
module 2_edge_wang_tiles(rows, columns, tile_width) {
edges = [
for(y = [0:rows])
[
for(x = [0:columns])
[round(rands(0, 1, 1)[0]), round(rands(0, 1, 1)[0])]
]
];
for(y = [0:rows - 1]) {
for(x = [0:columns - 1]) {
i = (edges[y + 1][x][0] == 1 ? 1 : 0) +
(edges[y][x + 1][1] == 1 ? 2 : 0) +
(edges[y][x][0] == 1 ? 4 : 0) +
(edges[y][x][1] == 1 ? 8 : 0);
translate([x, y] * tile_width)
children(i);
}
}
}