1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-02-24 09:33:26 +01:00
dotSCAD/examples/maze/random_scala.scad

26 lines
649 B
OpenSCAD
Raw Normal View History

2020-03-05 08:44:35 +08:00
use <experimental/mz_hamiltonian.scad>;
2020-03-04 10:16:27 +08:00
2020-03-05 08:44:35 +08:00
module random_scala(start, rows, columns, width, height) {
line = mz_hamiltonian(start, rows, columns);
2020-03-04 10:16:27 +08:00
for(i = [0:len(line) - 1]) {
2020-03-05 08:44:35 +08:00
p1 = line[i];
translate(p1)
2020-03-04 10:16:27 +08:00
linear_extrude(height * i * 2 + height)
square(width + 0.01, center = true);
2020-03-05 08:44:35 +08:00
p2 = line[(i + 1) % len(line)];
translate(p1 + (p2 - p1) / 2)
2020-03-04 10:16:27 +08:00
linear_extrude(height * (2 * i + 1) + height)
square(width + 0.01, center = true);
}
}
random_scala(
2020-03-05 08:44:35 +08:00
start = [0, 0],
2020-03-04 10:16:27 +08:00
rows = 2,
2020-03-05 08:44:35 +08:00
columns = 5,
2020-03-04 10:16:27 +08:00
width = .5,
height = .25
);