canvas: add caption placement and text sizing controls

Merged
AN
4d ago
+706-60

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.nodeStyle gains captionPosition (inside/above/below/left/right) and captionGap; outside captions use the canvas foreground color and the fixed fontSize, now defaulting to 6.
  • Inside captions in auto-size mode fit on one line within textFillRatio of the node radius; set textFillRatio to 0 to use fontSize with 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.fontSize now sizes link labels in 2D and 3D, defaulting to 6, with per-link fontSize still 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 captionGap throws a RangeError in setConfig.
  • The example adds a caption placement toggle that defaults to above, and docs clarify that square/cube size is half the side length.
  • Stacks on #45; release both as canvas-v0.5.0 with updated MIGRATION-v0.5.0.md guidance once #45 merges.