Skip to content

fix: rotate LED silkscreen rectangles with their footprints - #4816

Merged
ShiboSoftwareDev merged 7 commits into
tscircuit:mainfrom
Devesh36:fix/led-silkscreen-rect-rotation
Oct 21, 2026
Merged

ShiboSoftwareDev merged 7 commits into
tscircuit:mainfrom
Devesh36:fix/led-silkscreen-rect-rotation

Conversation

@Devesh36

@Devesh36 Devesh36 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the LED outline rotation reproduced in #4622. Rotating C540985 or C540986 by 45° now rotates the silkscreen rectangle together with its pads.

Use the footprint's full placement transform for both the rectangle orientation and its axis-aligned size, including bottom-layer mirroring. getPcbSize() now reuses the existing rotated-rectangle bounds helper, so arbitrary angles report the space the rectangle occupies. Keep the existing width/height swap for 90° and 270° placements.

The regression compares the rectangle corners and reported dimensions with an equivalent emitted path on both PCB layers and inside rotated groups. At 45°, the previous code reported a 6 mm width for a 6 × 2 mm rectangle; its actual bounds are approximately 5.657 × 5.657 mm. Transform names specify their coordinate spaces, and rotation names specify direction and units.

Before

LED outlines stay axis-aligned

After

LED outlines follow the pads

Validation: 32 silkscreen-related tests passed, TypeScript passed, build passed, and changed TypeScript files pass formatting. The geometry regression fails against the original implementation; the added bounds assertions also fail against the previous PR revision. The silkscreen snapshots remain valid after correcting the bounds.

@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
tscircuit-core-benchmarks Ready Ready Preview Oct 21, 2026 4:22pm UTC

Request Review

},
width: finalWidth,
height: finalHeight,
ccw_rotation: isRotated90Degrees ? 0 : rotation,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also update getPcbSize() to account for arbitrary rotation? The rectangle now rotates, but its reported bounds still use the unrotated width/height. Please add a bounds regression test too.

// orientation (+X right, +Y top, CCW degrees), including bottom-layer flips.
// Use the same placement matrix as SilkscreenPath's transformed corners.
const transform = this._computePcbGlobalTransformBeforeLayout()
const rotation = (Math.atan2(transform.b, transform.a) * 180) / Math.PI

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handbook violation

@ShiboSoftwareDev
ShiboSoftwareDev merged commit a2774e0 into tscircuit:main Oct 21, 2026
17 of 18 checks passed
@tscircuitbot

Copy link
Copy Markdown
Contributor

Thank you for your contribution! 🎉

PR Rating: ⭐⭐
Impact: Minor

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


This branch was successfully deployed

1 active deployment
Preview — 30ca51c9 Deployed Oct 21, 2026 by vercel[bot]
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.

3 participants