1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
dotSCAD/examples/tiles/knot_tiles.scad
Justin Lin 3678b8b6d7 move
2021-10-04 07:58:45 +08:00

51 lines
1.6 KiB
OpenSCAD

use <experimental/tile_truchet.scad>;
use <arc.scad>;
use <line2d.scad>;
use <select.scad>;
size = [50, 25];
tile_width = 5;
line_width = 1;
$fn = 12; // 4, 8, 12 ....
for(tile = tile_truchet(size)) {
x = tile[0];
y = tile[1];
i = tile[2];
translate([x, y] * tile_width)
select(i) {
tile00(tile_width, line_width);
tile01(tile_width, line_width);
tile02(tile_width, line_width);
tile03(tile_width, line_width);
};
}
module tile00(tile_width, line_width) {
arc(0.5 * tile_width, [0, 90], line_width);
translate([tile_width, tile_width])
arc(0.5 * tile_width, [180, 270], line_width);
}
module tile01(tile_width, line_width) {
translate([0, tile_width])
arc(0.5 * tile_width, [270, 360], line_width);
translate([tile_width, 0])
arc(0.5 * tile_width, [90, 180], line_width);
}
module tile02(tile_width, line_width) {
half_width = tile_width * 0.5;
line2d([half_width, 0], [half_width, tile_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT");
line2d([0, half_width], [half_width - line_width, half_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT");
line2d([half_width + line_width, half_width], [tile_width, half_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT");
}
module tile03(tile_width, line_width) {
half_width = tile_width * 0.5;
line2d([0, half_width], [tile_width, half_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT");
line2d([half_width, 0], [half_width, half_width - line_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT");
line2d([half_width, tile_width], [half_width, half_width + line_width], line_width, p1Style = "CAP_BUTT", p2Style = "CAP_BUTT");
}