1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-26 16:04:46 +02:00

add tile_truchet

This commit is contained in:
Justin Lin
2021-07-30 10:55:36 +08:00
parent 1812e732bb
commit 8829123ade
2 changed files with 43 additions and 23 deletions

View File

@@ -1,28 +1,19 @@
use <experimental/tile_truchet.scad>;
use <line2d.scad>;
use <util/rand.scad>;
module tiled_lines(size, step, line_width = 1) {
sizexy = is_num(size) ? [size, size] : size;
s = is_undef(step) ? line_width * 2 : step;
module rand_diagonal_line(x, y, size) {
if(rand(0, 1) >= 0.5) {
line2d([x, y], [x + size, y + size], width = line_width);
}
else {
line2d([x + size, y], [x, y + size], width = line_width);
}
}
for(x = [0:s:sizexy[0] - s]) {
for(y = [0:s:sizexy[1] - s]) {
rand_diagonal_line(x, y, s);
}
}
}
size = [50, 25];
step = 2;
tile_width = 5;
line_width = 1;
tiled_lines(size, step, line_width);
for(tile = tile_truchet(size)) {
x = tile[0];
y = tile[1];
i = tile[2];
if(i <= 1) {
line2d([x, y] * tile_width , [x + 1, y + 1] * tile_width, width = line_width);
}
else {
line2d([x + 1, y] * tile_width, [x, y + 1] * tile_width, width = line_width);
}
}