Add LEGEND_EMBOSSED parameter for raised, paint-rollable legends#24
Open
rajivtctech wants to merge 1 commit into
Open
Add LEGEND_EMBOSSED parameter for raised, paint-rollable legends#24rajivtctech wants to merge 1 commit into
rajivtctech wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in
LEGEND_EMBOSSEDmode 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
LEGEND_EMBOSSEDfalsefalse= unchanged carved/flush behavior.LEGEND_EMBOSSED_HEIGHT0.7 mmLEGEND_EMBOSSED_BURIED0.5 mmFlat-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()— whenLEGEND_EMBOSSED=truethe configuration must produce a flat top:KEY_PROFILE=""andDISH_DEPTH=0, orKEY_PROFILE=""andDISH_TYPEnot in{"sphere", "cylinder", "inv_pyramid"}, orKEY_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_with_emboss()short-circuits to the existingrender_keycap()wheneverLEGEND_EMBOSSEDisfalse— 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 newemboss_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).ROWrendering 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 textLEGEND_EMBOSSED=true+DISH_TYPE="flat"— flat keycap with raised textLEGEND_EMBOSSED=true+ROW=[["Q"],["W"],["E"]]— three flat keycaps each with its own raised legendLEGEND_EMBOSSED=true+ dished sphere — halts with the flat-top assertion message; no STL producedDocumentation 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.