1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-22 14:23:23 +02:00
This commit is contained in:
Justin Lin
2022-04-06 12:11:38 +08:00
parent c810e30003
commit 029ddc4150
10 changed files with 68 additions and 97 deletions

View File

@@ -12,7 +12,7 @@ rotate([90, 0, -109])
translate([0, -2, -2]) translate([0, -2, -2])
ellipse_extrude(semi_minor_axis, height = 4, slices = slices) ellipse_extrude(semi_minor_axis, height = 4, slices = slices)
translate([3, 0, -2]) translate([3, 0, -2])
polygon(midpt_smooth(shape_taiwan(170), smooth_times, true)); polygon(midpt_smooth(shape_taiwan(170), smooth_times, true));
// From: https://www.thingiverse.com/thing:1362048 // From: https://www.thingiverse.com/thing:1362048

View File

@@ -13,12 +13,12 @@ module blocks(points) {
// Well, quick and dirty!! // Well, quick and dirty!!
color("MediumSeaGreen") color("MediumSeaGreen")
translate([3, -5, -27]) translate([3, -5, -27])
for(pt = vx_polygon([for(p = shape_taiwan(92, distance = 1)) [round(p[0]), round(p[1])]], filled = true)) { for(pt = vx_polygon([for(p = shape_taiwan(92, distance = 1)) [round(p[0]), round(p[1])]], filled = true)) {
translate(pt) translate(pt)
linear_extrude(1, scale = 0.5) linear_extrude(1, scale = 0.5)
square(1, center = true); square(1, center = true);
} }
color(c = [0.3, 0.3, 0.3]) { color(c = [0.3, 0.3, 0.3]) {
blocks(vx_sphere(10)); blocks(vx_sphere(10));

View File

@@ -9,21 +9,15 @@ $fn = 24;
translate([tile_width, tile_width] / 2) translate([tile_width, tile_width] / 2)
for(tile = tile_w2e(size)) { for(tile = tile_w2e(size)) {
x = tile[0]; translate([tile.x, tile.y] * tile_width)
y = tile[1]; sample_tile(tile[2], tile_width, tile_thickness);
i = tile[2];
translate([x, y] * tile_width)
sample_tile(i, tile_width, tile_thickness);
} }
translate([0, tile_width * (size[1] + 1)] + [tile_width, tile_width] / 2) translate([0, tile_width * (size[1] + 1)] + [tile_width, tile_width] / 2)
color("green") color("green")
for(tile = tile_w2e(size)) { for(tile = tile_w2e(size)) {
x = tile[0]; translate([tile.x, tile.y] * tile_width)
y = tile[1]; path_tile(tile[2], tile_width);
i = tile[2];
translate([x, y] * tile_width)
path_tile(i, tile_width);
} }
module sample_tile(n, width, thickness) { module sample_tile(n, width, thickness) {

View File

@@ -7,12 +7,8 @@ tile_width = 5;
line_width = 1; line_width = 1;
for(tile = tile_hitomezashi(size)) { for(tile = tile_hitomezashi(size)) {
x = tile[0]; translate([tile.x, tile.y] * tile_width)
y = tile[1]; select(tile[2]) {
i = tile[2];
translate([x, y] * tile_width)
select(i) {
tile00(tile_width, line_width); tile00(tile_width, line_width);
tile01(tile_width, line_width); tile01(tile_width, line_width);
tile02(tile_width, line_width); tile02(tile_width, line_width);

View File

@@ -10,12 +10,8 @@ line_width = 1;
$fn = 12; // 4, 8, 12 .... $fn = 12; // 4, 8, 12 ....
for(tile = tile_truchet(size)) { for(tile = tile_truchet(size)) {
x = tile[0]; translate([tile.x, tile.y] * tile_width)
y = tile[1]; select(tile[2]) {
i = tile[2];
translate([x, y] * tile_width)
select(i) {
tile00(tile_width, line_width); tile00(tile_width, line_width);
tile01(tile_width, line_width); tile01(tile_width, line_width);
tile02(tile_width, line_width); tile02(tile_width, line_width);

View File

@@ -14,38 +14,35 @@ module lavender(n, radius) {
module draw_acute_pie(p, r, a) { module draw_acute_pie(p, r, a) {
hull() { hull() {
linear_extrude(layer_thickness * 2) linear_extrude(layer_thickness * 2)
offset(-radius / 175) { offset(-radius / 175)
translate(p) translate(p)
rotate(a) rotate(a)
pie(r * 1.1, 72); pie(r * 1.1, 72);
}
linear_extrude(layer_thickness * 3) linear_extrude(layer_thickness * 3)
offset(-radius / 100) { offset(-radius / 100)
translate(p) translate(p)
rotate(a) rotate(a)
pie(r, 72); pie(r, 72);
}
} }
} }
module draw_obtuse_pie(p, r, a) { module draw_obtuse_pie(p, r, a) {
hull() { hull() {
linear_extrude(layer_thickness * 2) linear_extrude(layer_thickness * 2)
offset(-radius / 175) { offset(-radius / 175)
translate(p) translate(p)
rotate(a) rotate(a)
pie(r * 1.1, 36); pie(r * 1.1, 36);
}
linear_extrude(layer_thickness * 3) linear_extrude(layer_thickness * 3)
offset(-radius / 100) { offset(-radius / 100)
translate(p) translate(p)
rotate(a) rotate(a)
pie(r, 36); pie(r, 36);
} }
} }
}
v1 = points[0] - points[1]; v1 = points[0] - points[1];
v2 = points[2] - points[1]; v2 = points[2] - points[1];
@@ -81,7 +78,6 @@ module lavender(n, radius) {
color("Lime") color("Lime")
hull() { hull() {
linear_extrude(layer_thickness) linear_extrude(layer_thickness)
polygon(points); polygon(points);
linear_extrude(layer_thickness * 2) linear_extrude(layer_thickness * 2)

View File

@@ -27,17 +27,13 @@ module magic_apartment(width, rows, columns, floors, up_down_rand, people) {
translate([0, 0, width / 4 + width / 30]) translate([0, 0, width / 4 + width / 30])
scale([1, 1, 0.5]) scale([1, 1, 0.5])
for(z = [0:floors - 1]) { for(z = [0:floors - 1], y = [0:rows - 1], x = [0:columns - 1]) {
for(y = [0:rows - 1]) {
for(x = [0:columns - 1]) {
translate([x * width, y * width, z * width]) translate([x * width, y * width, z * width])
tile(width, [ tile(width, [
edges[z][y][x][0], edges[z][y][x + 1][1], edges[z][y + 1][x][0], edges[z][y][x][1], edges[z][y][x][0], edges[z][y][x + 1][1], edges[z][y + 1][x][0], edges[z][y][x][1],
edges[z + 1][y][x][0], edges[z + 1][y][x + 1][1], edges[z + 1][y + 1][x][0], edges[z + 1][y][x][1], edges[z + 1][y][x][0], edges[z + 1][y][x + 1][1], edges[z + 1][y + 1][x][0], edges[z + 1][y][x][1],
], up_down_rand); ], up_down_rand);
} }
}
}
// base // base
linear_extrude(width / 30) linear_extrude(width / 30)
@@ -49,29 +45,25 @@ module magic_apartment(width, rows, columns, floors, up_down_rand, people) {
linear_extrude(width * floors / 2 + width / 15) linear_extrude(width * floors / 2 + width / 15)
square([width * columns, width / 30]); square([width * columns, width / 30]);
for(f = [1:2:floors * 4 - 1]) { for(f = [1:2:floors * 4 - 1], c = [1:2:columns * 4 - 1]) {
for(c = [1:2:columns * 4 - 1]) {
if(choose([true, false])) { if(choose([true, false])) {
translate([width / 4 * c, 0, width / 8 * f]) translate([width / 4 * c, 0, width / 8 * f])
cube([rand(width / 15, width / 15 * 2) , width / 15, rand(width / 15, width / 15 * 3)], center = true); cube([rand(width / 15, width / 15 * 2) , width / 15, rand(width / 15, width / 15 * 3)], center = true);
} }
} }
} }
}
translate([-width / 30, 0]) translate([-width / 30, 0])
difference() { difference() {
linear_extrude(width * floors / 2 + width / 15) linear_extrude(width * floors / 2 + width / 15)
square([width / 30, width * rows + width / 30]); square([width / 30, width * rows + width / 30]);
for(f = [1:2:floors * 4 - 1]) { for(f = [1:2:floors * 4 - 1], r = [1:2:rows * 4 - 1]) {
for(r = [1:2:rows * 4 - 1]) {
if(choose([true, false])) { if(choose([true, false])) {
translate([0, width / 4 * r, width / 8 * f]) translate([0, width / 4 * r, width / 8 * f])
cube([width / 15, rand(width / 15, width / 15 * 2), rand(width / 15, width / 15 * 3)], center = true); cube([width / 15, rand(width / 15, width / 15 * 2), rand(width / 15, width / 15 * 3)], center = true);
} }
} }
} }
}
// tiles, just quick and dirty // tiles, just quick and dirty
module tile(width, edges, up_down_rand) { module tile(width, edges, up_down_rand) {

View File

@@ -47,8 +47,7 @@ module random_town_square(size, tileW, layerH) {
module draw_tiles(tiles) { module draw_tiles(tiles) {
rows = len(tiles); rows = len(tiles);
columns = len(tiles[0]); columns = len(tiles[0]);
for(y = [0:rows - 1]) { for(y = [0:rows - 1], x = [0:len(tiles[y]) - 1]) {
for(x = [0:len(tiles[y]) - 1]) {
translate([x, rows - y - 1] * tileW) { translate([x, rows - y - 1] * tileW) {
draw_tile(tiles[y][x], tileW, layerH); draw_tile(tiles[y][x], tileW, layerH);
*color("white") *color("white")
@@ -57,7 +56,6 @@ module random_town_square(size, tileW, layerH) {
} }
} }
} }
}
module draw_tile(tile, tileW, layerH) { module draw_tile(tile, tileW, layerH) {
if(has(["F2", "F4", "F6"], tile)) { if(has(["F2", "F4", "F6"], tile)) {

View File

@@ -12,11 +12,10 @@ module tiled_line_mobius(size, twist, line_diameter = 1) {
[ [
for(tile = tile_truchet(size)) for(tile = tile_truchet(size))
let( let(
x = tile[0], x = tile.x,
y = tile[1], y = tile.y
i = tile[2]
) )
i <= 1 ? [[x, y], [x + 1, y + 1]] : [[x + 1, y], [x, y + 1]] tile[2] <= 1 ? [[x, y], [x + 1, y + 1]] : [[x + 1, y], [x, y + 1]]
], ],
[ [
for(i = [0:size[1] - 1]) for(i = [0:size[1] - 1])