canvas: add caption placement and text sizing controls
Merged
AN
4d ago+706+706+012345678901234567890123456789-60-60-01234567890123456789
Summary
- Add configurable 2D node caption placement and gap, including an example toggle and side selector.
- Add shared link text sizing with per-link overrides; use one node text-size control and default it to 6.
- Stack on #45 and update migration guidance for a combined canvas-v0.5.0 release after both PRs merge.
Compatibility
This PR depends on #45 and its breaking 2D/3D API changes. After #45 merges, retarget this PR to main and release both changes together as canvas-v0.5.0. No package version or release tag is created here.
Validation
- Canvas tests: 402 passed (jsdom emits existing canvas getContext warnings)
- Canvas build, lint, and typecheck passed
- Chromium example: caption positioning, gap and node/link text sizing
Summary by cubic
Adds configurable 2D node caption placement and shared link text sizing for the canvas component.
twoD.nodeStylegainscaptionPosition(inside/above/below/left/right) andcaptionGap; outside captions use the canvas foreground color and the fixedfontSize, now defaulting to 6.- Inside captions in auto-size mode fit on one line within
textFillRatioof the node radius; settextFillRatioto 0 to usefontSizewith wrapping that stays inside the node, truncating to one line when two cannot fit. Captions that cannot be placed are cached as omitted and re-attempted only when the font, size, or selection weight changes. linkStyle.fontSizenow sizes link labels in 2D and 3D, defaulting to 6, with per-linkfontSizestill taking precedence.- Viewport culling counts outside captions and caches their measurements, so a caption stays visible when its node is offscreen.
- A non-finite or negative
captionGapthrows aRangeErrorinsetConfig. - The example adds a caption placement toggle that defaults to
above, and docs clarify that square/cubesizeis half the side length. - Stacks on #45; release both as
canvas-v0.5.0with updatedMIGRATION-v0.5.0.mdguidance once #45 merges.