Skip to content

feat: add knockout rendering for silkscreen text#684

Open
buildingvibes wants to merge 1 commit intotscircuit:mainfrom
buildingvibes:feat-silkscreen-knockout-text
Open

feat: add knockout rendering for silkscreen text#684
buildingvibes wants to merge 1 commit intotscircuit:mainfrom
buildingvibes:feat-silkscreen-knockout-text

Conversation

@buildingvibes
Copy link

Summary

  • Add knockout rendering support for pcb_silkscreen_text elements in the 3D viewer
  • When is_knockout is true, draws a filled silkscreen rectangle with the text cut out
  • Supports knockout_padding for configurable padding around the text
  • Handles rotation and bottom layer rendering
  • Matches the same approach used for pcb_copper_text knockout (canvas destination-out compositing)

This completes the 3d-viewer checklist item from tscircuit/tscircuit#770.

Changes

src/utils/silkscreen-texture.ts

  • Added knockout branch in the silkscreen text rendering loop
  • When is_knockout is set, computes padding (with sensible defaults based on font size), draws a filled rectangle at the anchor position, then cuts out the text using globalCompositeOperation = "destination-out"
  • Normal (non-knockout) text rendering is unchanged

stories/SilkscreenText/SilkscreenTextKnockout.stories.tsx

  • New story demonstrating knockout silkscreen text with: default padding, custom padding, rotation, and bottom layer rendering side by side with normal text

Test plan

  • Verify knockout story renders correctly in Storybook (filled rect with text cut out)
  • Verify normal silkscreen text is unchanged
  • Verify bottom layer knockout renders correctly
  • Verify rotated knockout text renders correctly
  • Verify custom padding works
  • Build passes (bun run build)
  • Format passes (bun run format:check)

Add support for is_knockout and knockout_padding on pcb_silkscreen_text
elements in the 3D viewer. When is_knockout is true, a filled silkscreen
rectangle is drawn with the text cut out using canvas destination-out
compositing, matching the approach used for pcb_copper_text knockout.

Includes a story demonstrating knockout text with default padding,
custom padding, rotation, and bottom layer rendering.
@vercel
Copy link

vercel bot commented Feb 10, 2026

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

Project Deployment Actions Updated (UTC)
3d-viewer Ready Ready Preview, Comment Feb 10, 2026 8:09am

Request Review

@buildingvibes
Copy link
Author

Hi! Following up - all CI checks pass (format, test, type-check, Vercel deploy). This adds knockout rendering for silkscreen text in the 3D viewer, matching the existing copper text knockout pattern. Happy to adjust anything!

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.

1 participant