2020-01-28 09:08:48 +08:00
|
|
|
use <line2d.scad>;
|
2020-02-13 17:01:28 +08:00
|
|
|
use <util/rand.scad>;
|
2019-08-10 09:50:06 +08:00
|
|
|
|
2020-02-13 17:01:28 +08:00
|
|
|
module tiled_lines(size, step, line_width = 1) {
|
2019-08-10 09:50:06 +08:00
|
|
|
sizexy = is_num(size) ? [size, size] : size;
|
|
|
|
s = is_undef(step) ? line_width * 2 : step;
|
|
|
|
|
|
|
|
module rand_diagonal_line(x, y, size) {
|
2020-02-13 17:01:28 +08:00
|
|
|
if(rand(0, 1) >= 0.5) {
|
2019-08-10 09:50:06 +08:00
|
|
|
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;
|
2020-02-13 17:02:20 +08:00
|
|
|
line_width = 1;
|
2019-08-10 09:50:06 +08:00
|
|
|
|
2020-02-13 17:01:28 +08:00
|
|
|
tiled_lines(size, step, line_width);
|