tscircuit / tscircuit/image-utils

Hidden SVG paths and groups still become painted BRep geometry

Open
#34 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
0
Forks
10
PR merge metrics
No merged PRs in 30d

Description

At v0.0.10 (81a79bc3665a4fedab02d3a8e273b9ac5d1af906), getSvgBRepShapes includes path geometry hidden with display or visibility. This can turn a hidden editor layer into visible output geometry.

Minimal reproduction (Bun from repository root):

import { identity } from "transformation-matrix"
import { getSvgBRepShapes } from "./lib/svg-to-brep-shapes"
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
  <g display="none"><path d="M1 1 H9 V9 H1 Z"/></g>
</svg>`
console.log(getSvgBRepShapes({ svg, width: 10, height: 10, transform: identity() }).length)
// 1; expected 0 for the painted output

I also compared the following complete 10-by-10 SVGs using the installed @napi-rs/canvas SVG loader, drawing onto a transparent canvas and checking center pixel alpha:

Single square case BRep shapes SVG center alpha
visible control 1 255
path display="none" 1 0
path style="display: none" 1 0
parent g display="none" 1 0
path visibility="hidden" 1 0

The SVG rendering model excludes a display:none subtree from rendering; visibility:hidden suppresses painting. A fix should resolve display and effective visibility before emitting painted BRep shapes. The semantics differ: visibility is inherited and a descendant can override it, whereas a descendant cannot restore rendering inside a display:none subtree.

This does not use defs/symbols or multiple nested rings. I separately reproduced the hidden-group result against the local #32 implementation that skips definition subtrees, so it is distinct from #31/#32. The current regex-based path collection on main does not inspect these style attributes or ancestor state.

The five table cases were executed locally. Native renderer behavior for visibility inheritance overrides was not used as an oracle; such cases need specification-based regression coverage. Prepared with Codex (Astra) assistance.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/svg-to-brep-shapes and reproduce the Bun example from the issue, then inspect the current regex-based path collection. Ensure display="none" subtrees and hidden visibility states do not emit painted BRep shapes while descendant visibility overrides follow SVG inheritance rules; add regression coverage for the five listed cases and specification-based inheritance overrides.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.