Add vector_legend() for svg/dxf legends (#103) - #223
Open
MatthewDelprado wants to merge 1 commit into
Open
Conversation
vector_legend(file, position, size) works like legend() but imports a vector file instead of rendering text. Backed by new $vector_legends / $front_vector_legends lists in settings.scad and a keyimage() module in features/legends.scad that mirrors keytext() (import() + resize() instead of text()). Honours $outset_legends / $inset_legend_depth and follows the dished top via top_of_key(), exactly like text legends. $vector_legend_fn sets curve resolution. front_vector_legend() covers the front face. Notes: - import() runs from src/features/legends.scad, so an absolute path is the reliable choice; a bare filename next to the top-level .scad resolves via OpenSCAD's deprecated document-root fallback (prints a notice). Documented in the README, the example header, and the settings comment. - import() reads vector fills only - strokes/text must be outlined first. - Does not work in the Thingiverse customizer, same as text $legends. customizer.scad is not regenerated here (matches PR rsheldiii#173; expand.rb also currently needs `ruby -E UTF-8:UTF-8` on a clean checkout). Adds examples/vector_legend.scad (svg + dxf + front + text-stacking) with a hand-authored placeholder heart.svg / heart.dxf, and a README section. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Closes #103.
Adds
vector_legend(file, position, size)— a chainable transformation that drops a vector file onto a cap the same waylegend()drops text.How it works
Mirrors the text-legend path as closely as I could:
legend()/front_legend()→$legends/$front_legendsvector_legend()/front_vector_legend()→$vector_legends/$front_vector_legendskeytext()(text()+linear_extrude)keyimage()(import()+resize()+linear_extrude)keyimage()sits right next tokeytext()infeatures/legends.scad;legends()loops the two new lists after the existing text loops.$outset_legends/$inset_legend_depthand follows the dished top viatop_of_key(), identical to text.sizeis the artwork width in mm; height keeps the file's aspect ratio.$vector_legend_fnsets import curve resolution.$vector_legends/$front_vector_legendsdefault[], solen(...) > 0skips the new blocks and plain keys render byte-identical.Notes / things to decide
import()runs fromsrc/features/legends.scad, so it resolves paths relative to that dir, not the user's.scad. A bare filename next to the top-level file still works via OpenSCAD's document-root fallback but prints aDEPRECATED … found in document rootnotice. I've documented "use an absolute path" in the README, the example header, and thesettings.scadcomment, and the example acknowledges the notice. Open to a better approach if you have one.vector_legendrather thansvg_legendsinceimport()takes DXF too (Picture-based legends? #103 asks for "picture" legends generally).keyimage()as the internal module name keeps thekey*prefix.customizer.scadnot regenerated. Matches the last legends change (Font can be explicitly set on a legend #173 / 7a5d2f0 touched onlysrc/).expand.rbalso currently needsruby -E UTF-8:UTF-8on a clean checkout, and a clean regen from master pulls in unrelated drift. This feature doesn't work in the Thingiverse customizer anyway (same as text$legends).import()reads fills only, and a self-overlapping outline (traced logos, brush art) extrudes to a non-manifold cut — README notes theoffset()roundtrip fix.Example / testing
examples/vector_legend.scadcovers inset, outset, text-stacking, DXF, andfront_vector_legend(), using a hand-authored placeholderheart.svg/heart.dxf. Rendered on OpenSCAD 2026.06; SVG + DXF + front + regressions all check out.🤖 Generated with Claude Code