Skip to content

Add vector_legend() for svg/dxf legends (#103) - #223

Open
MatthewDelprado wants to merge 1 commit into
rsheldiii:masterfrom
MatthewDelprado:vector-legend
Open

Add vector_legend() for svg/dxf legends (#103)#223
MatthewDelprado wants to merge 1 commit into
rsheldiii:masterfrom
MatthewDelprado:vector-legend

Conversation

@MatthewDelprado

Copy link
Copy Markdown

Closes #103.

Adds vector_legend(file, position, size) — a chainable transformation that drops a vector file onto a cap the same way legend() drops text.

dcs_row(1) vector_legend("logo.svg", size=9) key();

How it works

Mirrors the text-legend path as closely as I could:

text vector
legend() / front_legend()$legends / $front_legends vector_legend() / front_vector_legend()$vector_legends / $front_vector_legends
keytext() (text() + linear_extrude) keyimage() (import() + resize() + linear_extrude)
  • keyimage() sits right next to keytext() in features/legends.scad; legends() loops the two new lists after the existing text loops.
  • Honours $outset_legends / $inset_legend_depth and follows the dished top via top_of_key(), identical to text.
  • size is the artwork width in mm; height keeps the file's aspect ratio. $vector_legend_fn sets import curve resolution.
  • Inert by default — $vector_legends / $front_vector_legends default [], so len(...) > 0 skips the new blocks and plain keys render byte-identical.

Notes / things to decide

  • Path resolution. import() runs from src/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 a DEPRECATED … found in document root notice. I've documented "use an absolute path" in the README, the example header, and the settings.scad comment, and the example acknowledges the notice. Open to a better approach if you have one.
  • Naming. Went with vector_legend rather than svg_legend since import() takes DXF too (Picture-based legends? #103 asks for "picture" legends generally). keyimage() as the internal module name keeps the key* prefix.
  • customizer.scad not regenerated. Matches the last legends change (Font can be explicitly set on a legend #173 / 7a5d2f0 touched only src/). expand.rb also currently needs ruby -E UTF-8:UTF-8 on 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).
  • Self-intersecting art. import() reads fills only, and a self-overlapping outline (traced logos, brush art) extrudes to a non-manifold cut — README notes the offset() roundtrip fix.

Example / testing

examples/vector_legend.scad covers inset, outset, text-stacking, DXF, and front_vector_legend(), using a hand-authored placeholder heart.svg / heart.dxf. Rendered on OpenSCAD 2026.06; SVG + DXF + front + regressions all check out.

🤖 Generated with Claude Code

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>
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.

Picture-based legends?

1 participant