Skip to content

Add LEGEND_EMBOSSED parameter for raised, paint-rollable legends#24

Open
rajivtctech wants to merge 1 commit into
riskable:masterfrom
rajivtctech:feature/embossed-legends
Open

Add LEGEND_EMBOSSED parameter for raised, paint-rollable legends#24
rajivtctech wants to merge 1 commit into
riskable:masterfrom
rajivtctech:feature/embossed-legends

Conversation

@rajivtctech
Copy link
Copy Markdown

Summary

Adds an opt-in LEGEND_EMBOSSED mode where legends are extruded upward as raised text on top of a flat keycap rather than carved into a dished one. Motivation: highlighting legends in a contrasting colour by rolling a paint roller across the top so paint deposits only on the raised letters — much faster and more repeatable across a whole keyboard than paint-filling carved/recessed legends.

New parameters

Parameter Default Purpose
LEGEND_EMBOSSED false Toggle. false = unchanged carved/flush behavior.
LEGEND_EMBOSSED_HEIGHT 0.7 mm Total extrusion thickness of the raised text.
LEGEND_EMBOSSED_BURIED 0.5 mm How far the bottom of the text is buried into the top so the join is solid.

Flat-top constraint (enforced)

A paint roller cannot follow a curved surface, so a dished top would never receive ink on the embossed letters. The customizer enforces this with a top-level assert() — when LEGEND_EMBOSSED=true the configuration must produce a flat top:

  1. KEY_PROFILE="" and DISH_DEPTH=0, or
  2. KEY_PROFILE="" and DISH_TYPE not in {"sphere", "cylinder", "inv_pyramid"}, or
  3. KEY_PROFILE="xda" (the only built-in flat-top profile).

Dished profiles (riskeycap, gem, dsa, dcs, dss, kat, kam) are rejected with a message that lists the valid configurations and prints the offending parameter values.

Implementation

Purely additive aside from one wrapper at the very end of the file:

-render_keycap(RENDER);
+render_keycap_with_emboss(RENDER);

render_keycap_with_emboss() short-circuits to the existing render_keycap() whenever LEGEND_EMBOSSED is false — so every existing configuration is bit-for-bit unchanged. When the flag is on, the wrapper renders the keycap with empty legends (so nothing is carved) and adds raised text via a new emboss_legends_using_globals() module that reuses all the existing positioning parameters (LEGEND_TRANS, LEGEND_ROTATION, LEGEND_FONTS, LEGEND_FONT_SIZES, LEGEND_SCALE, KEY_ROTATION, DISH_TILT).

Render targets that produce a legend object on its own (legends, row_legends, underset_mask, row_underset_masks) are skipped with a console note in embossed mode (the legends ARE the keycap body). ROW rendering is supported. Stems and custom render targets pass through unchanged.

Test plan

  • LEGEND_EMBOSSED=false + default dished sphere — renders identical to pre-change (regression)
  • LEGEND_EMBOSSED=true + DISH_DEPTH=0 — flat keycap with raised text
  • LEGEND_EMBOSSED=true + DISH_TYPE="flat" — flat keycap with raised text
  • LEGEND_EMBOSSED=true + ROW=[["Q"],["W"],["E"]] — three flat keycaps each with its own raised legend
  • LEGEND_EMBOSSED=true + dished sphere — halts with the flat-top assertion message; no STL produced

Documentation for the new parameters is available; happy to send it as a follow-up PR if useful — kept this PR scoped to the code change.

Introduces an opt-in mode where legends are extruded *upward* as raised
text on top of a flat keycap rather than being carved into a dished top.
This makes it practical to highlight legends in a contrasting colour by
running a paint roller across the top of the keycap: paint deposits only
on the raised letters, and any spill on the surrounding flat surface
wipes off cleanly. Paint-filling carved/recessed legends without making
a mess is fiddly, especially at scale; this approach is repeatable
across a whole keyboard's worth of caps in seconds.

New customizer parameters (all default to the existing carved behaviour
when LEGEND_EMBOSSED is left at false):

  LEGEND_EMBOSSED         (default: false)
  LEGEND_EMBOSSED_HEIGHT  (default: 0.7 mm; total extrusion thickness)
  LEGEND_EMBOSSED_BURIED  (default: 0.5 mm; how far the bottom of the
                           text is buried into the top of the keycap so
                           the join stays solid)

Flat-top constraint
-------------------

Because a paint roller is a rigid cylinder it cannot follow a curved
surface, so an embossed legend on a dished top would never receive ink.
The customizer enforces this with a top-level assert(): when
LEGEND_EMBOSSED=true, the configuration must produce a flat top, defined
as one of:

  (a) KEY_PROFILE = ""   AND  DISH_DEPTH = 0
  (b) KEY_PROFILE = ""   AND  DISH_TYPE not in
                              {"sphere", "cylinder", "inv_pyramid"}
  (c) KEY_PROFILE = "xda"  (the only built-in flat-top profile)

The dished profiles (riskeycap, gem, dsa, dcs, dss, kat, kam) are
rejected for embossing with an actionable error message that lists
the accepted configurations and prints the offending parameter values.

Implementation
--------------

The change is purely additive aside from a single one-line wrapper at
the very end of the file:

  -render_keycap(RENDER);
  +render_keycap_with_emboss(RENDER);

`render_keycap_with_emboss()` short-circuits to the existing
`render_keycap()` whenever LEGEND_EMBOSSED is false, so the carved /
flush-legend path is bit-for-bit unchanged for every existing
configuration. When LEGEND_EMBOSSED is true the wrapper renders the
keycap with empty legends (so nothing is carved) and adds the raised
text via a new `emboss_legends_using_globals()` module that reuses the
same LEGEND_TRANS / LEGEND_TRANS2 / LEGEND_ROTATION / LEGEND_ROTATION2
/ LEGEND_FONTS / LEGEND_FONT_SIZES / LEGEND_SCALE / KEY_ROTATION /
DISH_TILT positioning the existing carved-legend pipeline uses.

Render targets that produce a legend object on its own
(legends, row_legends, underset_mask, row_underset_masks) are not
meaningful in embossed mode (the legends ARE the keycap body) and are
skipped with a console note. ROW-mode rendering is supported. Stems and
custom render targets pass through unchanged.

Verification
------------

Smoke-tested with OpenSCAD on Linux:

  * LEGEND_EMBOSSED=false + default dished sphere
        -> renders identical to pre-change (regression check)
  * LEGEND_EMBOSSED=true + DISH_DEPTH=0
        -> renders, raised text on flat top
  * LEGEND_EMBOSSED=true + DISH_TYPE="flat"
        -> renders, raised text on flat top
  * LEGEND_EMBOSSED=true + ROW=[["Q"],["W"],["E"]]
        -> renders three flat-top keycaps each with its own raised legend
  * LEGEND_EMBOSSED=true + dished sphere (default DISH_DEPTH=1)
        -> halts with the flat-top assertion message and produces no STL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant