Bundles the symbol thumbnails alongside the .scad and a library README so the shared decoration library is self-contained, and adds a horseshoe magnet icon to the catalogue.
45 lines
1.5 KiB
OpenSCAD
45 lines
1.5 KiB
OpenSCAD
// Renders a flat top-down preview of a label for documentation.
|
|
// Combines the label outline, text and symbols into a single 2D silhouette
|
|
// so it stays legible from straight above (no shading needed).
|
|
use <../../lib/label-decorations/label-decorations.scad>;
|
|
|
|
example_text = "M5*8";
|
|
example_symbol1 = "side_pan";
|
|
example_symbol2 = "hex_rounded";
|
|
|
|
label_w = 36;
|
|
label_h = 11;
|
|
sym_size = 7;
|
|
sym_stroke = 1.0;
|
|
border_thickness = 0.6;
|
|
// Inset of left symbol from the left edge and right symbol from the right edge,
|
|
// matching Symbol{1,2}_XY.x in label.scad (defaults 1 and 2).
|
|
sym1_pad = 1;
|
|
sym2_pad = 2;
|
|
|
|
linear_extrude(0.4) {
|
|
// Rounded rectangular border for the label
|
|
difference() {
|
|
translate([0.5, 0.5])
|
|
offset(r = 0.5) square([label_w - 1, label_h - 1]);
|
|
translate([0.5, 0.5])
|
|
offset(delta = -border_thickness)
|
|
offset(r = 0.5) square([label_w - 1, label_h - 1]);
|
|
}
|
|
|
|
// Centered text
|
|
translate([label_w / 2, label_h / 2])
|
|
text(example_text, 4,
|
|
font = "Open Sans:Bold",
|
|
halign = "center", valign = "center");
|
|
|
|
// Left symbol
|
|
if (example_symbol1 != "none")
|
|
translate([sym_size / 2 + sym1_pad, label_h / 2])
|
|
symbol_shape(example_symbol1, sym_size, sym_stroke);
|
|
|
|
// Right symbol
|
|
if (example_symbol2 != "none")
|
|
translate([label_w - sym_size / 2 - sym2_pad, label_h / 2])
|
|
symbol_shape(example_symbol2, sym_size, sym_stroke);
|
|
}
|