mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-09-01 10:42:57 +02:00
refactor
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
include <hollow_out.scad>;
|
||||
|
||||
/* [Basic] */
|
||||
|
||||
shape = "Flower"; // [Flower, Circle]
|
||||
shape = "Heart"; // [Flower, Circle, Heart]
|
||||
model = "Outer"; // [Outer, Inner]
|
||||
width = 30;
|
||||
radius = 20;
|
||||
@@ -12,15 +13,14 @@ twist = 180;
|
||||
|
||||
/* [Advanced] */
|
||||
|
||||
convexity = 10;
|
||||
slices = 200;
|
||||
|
||||
module twist_bottle(model, height, thickness, twist, spacing, convexity, slices) {
|
||||
$fn = 96;
|
||||
$fn = 48;
|
||||
|
||||
module outer_container() {
|
||||
translate([0, 0, thickness])
|
||||
linear_extrude(height = height, twist = twist, convexity = convexity, slices = slices)
|
||||
linear_extrude(height = height, twist = twist, slices = slices)
|
||||
hollow_out(thickness) children();
|
||||
|
||||
linear_extrude(thickness)
|
||||
@@ -28,7 +28,7 @@ module twist_bottle(model, height, thickness, twist, spacing, convexity, slices)
|
||||
}
|
||||
|
||||
module inner_container() {
|
||||
linear_extrude(height = height, twist = twist, convexity = convexity, slices = slices)
|
||||
linear_extrude(height = height, twist = twist, slices = slices)
|
||||
hollow_out(thickness)
|
||||
offset(r = -thickness - spacing)
|
||||
children();
|
||||
@@ -42,8 +42,7 @@ module twist_bottle(model, height, thickness, twist, spacing, convexity, slices)
|
||||
if(model == "Outer") {
|
||||
outer_container()
|
||||
children();
|
||||
}
|
||||
else {
|
||||
} else if(model == "Inner") {
|
||||
translate([0, 0, height + thickness])
|
||||
rotate([180, 0, 0])
|
||||
inner_container()
|
||||
@@ -51,23 +50,53 @@ module twist_bottle(model, height, thickness, twist, spacing, convexity, slices)
|
||||
}
|
||||
}
|
||||
|
||||
module heart(radius, center = false) {
|
||||
sin45 = sin(45);
|
||||
cos45 = cos(45);
|
||||
|
||||
module heart_sub_component(radius) {
|
||||
diameter = radius * 2;
|
||||
$fn = 48;
|
||||
|
||||
translate([-radius * cos45, 0, 0])
|
||||
rotate(-45) union() {
|
||||
circle(radius);
|
||||
translate([0, -radius, 0])
|
||||
square(diameter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
offsetX = center ? 0 : radius + radius * cos(45);
|
||||
offsetY = center ? 1.5 * radius * sin45 - 0.5 * radius : 3 * radius * sin45;
|
||||
|
||||
translate([offsetX, offsetY, 0]) union() {
|
||||
heart_sub_component(radius);
|
||||
mirror([1, 0, 0]) heart_sub_component(radius);
|
||||
}
|
||||
}
|
||||
|
||||
if(shape == "Flower") {
|
||||
twist_bottle(model, height, thickness, twist, spacing, convexity, slices) union() {
|
||||
twist_bottle(model, height, thickness, twist, spacing, slices) union() {
|
||||
for(i = [0:3]) {
|
||||
rotate(90 * i)
|
||||
translate([radius * 0.5, 0, 0])
|
||||
circle(radius * 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(shape == "Circle") {
|
||||
twist_bottle(model, height, thickness, twist, spacing, convexity, slices) difference() {
|
||||
} else if(shape == "Circle") {
|
||||
twist_bottle(model, height, thickness, twist, spacing, slices) difference() {
|
||||
circle(radius);
|
||||
for(a = [0:120:240]) {
|
||||
rotate(a)
|
||||
translate([radius, 0, 0])
|
||||
circle(radius / 4);
|
||||
union() {
|
||||
for(a = [0:120:240]) {
|
||||
rotate(a)
|
||||
translate([radius, 0, 0])
|
||||
circle(radius / 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(shape == "Heart") {
|
||||
twist_bottle(model, height, thickness, twist, spacing, slices)
|
||||
heart(radius * 1.9 / (3 * sin(45) + 1), center = true);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user