diff main.scad @ 3:f5ff6f1a5454

better decal handling
author ark
date 2026-11-03 13:54 +0100
parents fe29ace8155e
children 4836a7408849
line wrap: on
line diff
--- a/main.scad	Tue Nov 03 10:08:08 2026 +0100
+++ b/main.scad	Tue Nov 03 13:54:57 2026 +0100
@@ -53,8 +53,10 @@
 /* [two-colour] */
 // split into body and decal, for a filament change on a single-colour printer
 two_colour = false;
-// width of the decal band along the outline
+// width of the decal band along the outline, on the face; it narrows by one layer height per layer
 band_width = 4; // [.5:.1:20]
+// decal thickness in layers, at most the glyph thickness less 2 layers
+decal_layers = 2; // [1:1:10]
 
 /* [washer] */
 // print the washers as part of the body, on the back of the glyph
@@ -83,7 +85,11 @@
 glyph_t = glyph_layers * lh;
 backing_t = backing ? backing_layers * lh : 0;
 total_t = glyph_t + backing_t;
-decal_t = 2 * lh;      // 2 layers
+// decal layers, leaving at least 2 layers of body
+decal_n = max(1, min(decal_layers, glyph_layers - 2));
+decal_t = decal_n * lh;
+// band width of the top decal layer
+band_top = band_width - (decal_n - 1) * lh;
 frame_t = lh;          // 1 layer
 
 magnet = attachment == "magnet";
@@ -158,6 +164,15 @@
              round(pause_z / lh), washers_on_body ? " of the body" : " of the washer"));
 if (magnet && seal_magnets && pocket_h > magnet_h + epsilon)
     echo(str("WARNING: pocket depth raised to ", pocket_h, " mm, whole layers"));
+if (two_colour) {
+    echo(str("decal: ", decal_n, " layers, ", decal_t, " mm, band ", band_width,
+             " mm on the face, ", band_top, " mm on the top layer"));
+    if (decal_n < decal_layers)
+        echo(str("WARNING: decal reduced to ", decal_n, " layers, glyph thickness less 2 layers"));
+    if (band_top < lw)
+        echo(str("WARNING: band on the top decal layer is ", band_top,
+                 " mm, less than a line width"));
+}
 if (washer_set < washer_min)
     echo(str("WARNING: washer height raised to ", washer_min, " mm"));
 for (h = holes) if (h[1] < fit_r_req)
@@ -213,14 +228,24 @@
     for (i = sel) _place() _glyph2d(i);
 }
 
-// Decal band: the outline minus the outline shrunk by the band width.
-module _band2d() {
+// Decal band of one layer: the outline minus the outline shrunk by the band
+// width. The band narrows by one layer height per layer, so its inner edge
+// slopes away from the body and the nozzle can reach the body's lower layers.
+// i: decal layer, 0 on the bed.
+module _band2d(i) {
     difference() {
         _placed2d();
-        offset(r = -band_width) _placed2d();
+        offset(r = -(band_width - i * lh)) _placed2d();
     }
 }
 
+// Decal layers in print orientation, one slab per layer.
+// e: downward extension of each slab, for subtracting from the body.
+module _decal3d(e = 0) {
+    for (i = [0 : decal_n - 1])
+        translate([0, 0, i * lh - e]) linear_extrude(lh + e) _band2d(i);
+}
+
 // Screw holes and countersinks, opening towards the bed, through washers
 // printed on the body. Nothing for magnets.
 module _holes() {
@@ -259,7 +284,7 @@
 }
 
 // Glyph body in print orientation, face on the bed. In two-colour mode the
-// decal band plus one line width is left out of the decal layers. Washers
+// decal is left out of the decal layers. Washers
 // printed on the body stand on its back, cut back to the outline of the back
 // so they do not overhang, with the magnet pockets at their top.
 // frame: include the frame (two-colour mode only).
@@ -279,9 +304,7 @@
         if (washers_on_body && magnet)
             for (h = holes) translate([h[0].x, h[0].y, total_t + washer_h]) _pocket();
         _holes();
-        if (two_colour)
-            translate([0, 0, -epsilon]) linear_extrude(decal_t + epsilon)
-                offset(delta = lw) _band2d();
+        if (two_colour) _decal3d(epsilon);
     }
     if (two_colour && frame) _frame();
 }
@@ -290,7 +313,7 @@
 // frame: include the frame.
 module decal(frame = true) {
     difference() {
-        linear_extrude(decal_t) _band2d();
+        _decal3d();
         _holes();
     }
     if (frame) _frame();
@@ -384,7 +407,7 @@
             : str(countersink ? "cs_" : "", "d", round(10 * screw_d), "w", washer_wall_lines,
                   "h", round(10 * washer_h), countersink ? str("c", round(10 * cs_washer)) : "")
         : str(g_name, "_", layout == "glyph" ? str("g", glyph_index, "_") : "",
-              two_colour ? "2c_" : "", backing ? "bk_" : "",
+              two_colour ? str("2cd", decal_n, "_") : "", backing ? "bk_" : "",
               magnet ? (washers_on_body ? str(magnet_str, "_") : "mg_")
                      : countersink ? "cs_" : "",
               washers_on_body ? str("wh", round(10 * washer_h), "_") : "",