Skip to content

Add rotation to texts - #228

Merged
seveibar merged 1 commit into
mainfrom
text-rotation
Aug 8, 2026
Merged

Add rotation to texts#228
seveibar merged 1 commit into
mainfrom
text-rotation

Conversation

@seveibar

@seveibar seveibar commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Text gains an optional rotation: degrees counter-clockwise about the anchor point in graphics (y-up) space, so rotation: 90 reads bottom-to-top. Unset text renders exactly as before.

Why

The schematic-trace-solver's new inline net labels (schematic-trace-solver#792) run parallel to the trace they name. On a vertical trace the debug visualization currently draws the name horizontally across the wire:

vertical inline label drawn horizontally

With this PR the solver can pass rotation: 90 and the text runs along the wire.

Implementation

  • Applied in all three renderers — getSvgFromGraphicsObject (SVG transform=rotate(…)), drawGraphicsToCanvas (ctx translate/rotate), and getPngBufferFromGraphicsObject (via strokeAlphabetText's existing rotationRadians). Each negates the angle into its clockwise screen space.
  • SVG bounds computation rotates the text box's corners about the anchor, so rotated text still contributes its true extents and is never clipped at the viewport edge.
  • Verified the PNG path renders bottom-to-top text correctly (software rasterizer).

bun test: 68 pass / 0 fail (one new snapshot). bunx tsc --noEmit clean.

Once released, I'll follow up in schematic-trace-solver to pass rotation from InlineNetLabelSolver.visualize().

🤖 Generated with Claude Code

Text gains an optional `rotation` - degrees counter-clockwise about the
anchor point in graphics (y-up) space, so `rotation: 90` reads
bottom-to-top. Applied in all three renderers (SVG, canvas, PNG), each
negating into its clockwise screen space; SVG bounds account for the
rotated corners so rotated text is never clipped.

Motivation: the schematic-trace-solver's inline net labels run parallel
to the trace they name, and a vertical trace's label was being drawn
horizontally across the wire.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
graphics-debug Ready Ready Preview Aug 8, 2026 7:17pm

Request Review

@seveibar
seveibar merged commit c8638dd into main Aug 8, 2026
4 checks passed
seveibar added a commit to tscircuit/schematic-trace-solver that referenced this pull request Aug 8, 2026
A vertical trace's inline label was drawn horizontally across the wire in
visualize() output. graphics-debug texts now support rotation, so pass 90
(counter-clockwise, bottom-to-top) for y-axis labels.

Needs graphics-debug with Text.rotation (tscircuit/graphics-debug#228);
the devDependency bump lands here once that releases.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@tscircuitbot

Copy link
Copy Markdown

Thank you for your contribution! 🎉

PR Rating: ⭐⭐
Impact: Minor

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


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.

2 participants