Simplify Decorations module

split a single decoration into its own module, and give it a most
generic translation. This makes the Decorations module cleaner and
easier to understand, because you can easily see exactly how much you
are translating each decoration.

Rather than translating the decoration to make it fit the other side of
the box, rotate it. It makes the translation cleaner, and it's a little
easier to understand. The decorations are the same on each side, just
rotated 180 degrees from one another.

I might still make all the left side decorations and rotate that 180
degrees for the right side.
This commit is contained in:
Joel Ebel 2018-05-18 00:55:11 -04:00
parent 3754009a43
commit 9ddb6d7516

View File

@ -129,6 +129,8 @@ TextColor = "White";
Dec_Thick = Vent ? Thick*1.001 + Filet : Thick/2; Dec_Thick = Vent ? Thick*1.001 + Filet : Thick/2;
// Separate vents with a square pillar by default. // Separate vents with a square pillar by default.
Dec_Spacing = Thick + Vent_width; Dec_Spacing = Thick + Vent_width;
// X offset to center of first vent
Dec_Offset = Thick*2 + PanelThick + PanelGap + Dec_Spacing - Vent_width/2;
// Resolution based on Round parameter // Resolution based on Round parameter
Resolution = Round ? 100: 4; Resolution = Round ? 100: 4;
@ -207,26 +209,35 @@ module MainBox() {
} }
/* Decoration: a single box decoration
*/
module decoration() {
translate([-Vent_width/2, -Thick, -Thick]) {
cube([Vent_width, Dec_Thick + Thick, Height/4 + Thick]);
}
}
/* Decorations: decorations module /* Decorations: decorations module
This module produces the box vents or decorations. This module produces the box vents or decorations.
*/ */
module Decorations() { module Decorations() {
union() { for (i=[0 : Dec_Spacing : Length/4]) {
// X offset to center of first vent translate([Dec_Offset + i, 0, 0]) {
DecOffset = Thick*2 + PanelThick + PanelGap + Dec_Spacing - Vent_width/2; decoration();
for (i=[0 : Dec_Spacing : Length/4]) { }
translate([DecOffset + i - Vent_width/2, -1, -1]) { translate([Length - Dec_Offset - i, 0, 0]) {
cube([Vent_width, Dec_Thick + 1, Height/4 + 1]); decoration();
}
translate([Length - Dec_Offset - i, Width, 0]) {
rotate([0, 0, 180]) {
decoration();
} }
translate([Length - DecOffset - i - Vent_width/2, -1, -1]) { }
cube([Vent_width, Dec_Thick + 1, Height/4 + 1]); translate([Dec_Offset + i, Width, 0]) {
} rotate([0, 0, 180]) {
translate([Length - DecOffset - i - Vent_width/2, Width - Dec_Thick, -1]) { decoration();
cube([Vent_width, Dec_Thick + 1, Height/4 + 1]);
}
translate([DecOffset + i - Vent_width/2, Width - Dec_Thick, -1]) {
cube([Vent_width, Dec_Thick + 1, Height/4 + 1]);
} }
} }
} }