8000 fix: make traced outlines visible on the select tools step by jasonmadigan · Pull Request #187 · tracefinity/tracefinity · GitHub
[go: up one dir, main page]

Skip to content

fix: make traced outlines visible on the select tools step - #187

Merged
jasonmadigan merged 2 commits into
mainfrom
fix/polygon-outline-visibility
Aug 19, 2026
Merged

jasonmadigan merged 2 commits into
mainfrom
fix/polygon-outline-visibility

Conversation

@jasonmadigan
@jasonmadigan jasonmadigan commented Aug 19, 2026 •
Copy link
Copy Markdown
Collaborator

Fixes #185.

Problem

uiScale normalised SVG stroke and handle sizes against a hardcoded 800px view width. That assumption fails for portrait images: the canvas is height-constrained, so it renders far narrower than 800px and everything scaled off uiScale came out proportionally too small.

Measured on a 1505x2048 corrected image at a normal laptop viewport:

before after
rendered canvas 426 x 580 CSS px unchanged
uiScale 1.88125 3.533
strokeWidth on screen 0.53 px 1.00 px
unselected stroke alpha 0.4 0.85
halo none 2.5 px at 0.55

A 0.53px line at 40% opacity over a photograph is not visible. The Select Tools step tells you to click the outlines and keeps the save button disabled until you do, so the flow dead-ends with no way forward on the canvas.

Change

  • Derive uiScale from the measured rendered width (fitted.width) instead of BASE_VIEW_WIDTH, so one unit is one CSS pixel at zoom 1. BASE_VIEW_WIDTH stays as the fallback until the size has been measured.
  • Raise unselected stroke opacity from 0.4 to 0.85 and fill from 0.06 to 0.08.
  • Paint a dark halo under every outline so it stays legible against arbitrary photographic backgrounds.

Side effect worth knowing

uiScale also drives vertex handles, vertex hit targets and edge hit targets. Those were undersized by the same factor and are now correct, which means they change size on every layout, not just the broken one. Where the canvas currently renders wider than 800px they get slightly smaller than before, because they now hold a true constant on-screen size rather than growing with the image.

Verification

  • tsc --noEmit clean.
  • eslint clean on all three changed files. Repo warning count unchanged.
  • next build succeeds.
  • vitest run: 9 files, 105 tests pass, up from 99. The 5 jsdom module-resolution errors reproduce on main with these changes stashed, so they are pre-existing and unrelated. They are also why there is no render test here: every jsdom-environment test file in the repo currently fails to load.
  • Verified visually by patching the computed values into a rendered editor and screenshotting. All four outlines legible where none were before.

Tests

The scale calculation was inline in the component with no way to assert it, so the second commit moves it to viewbox.ts as uiScaleFor and pins the behaviour:

  • one unit renders as one CSS pixel at zoom 1
  • on-screen size holds across zoom levels (0.5 to 20) and across image aspects
  • falls back to the fixed width before the render has been measured
  • never returns zero or a negative scale

Plus a direct regression test: the old fixed-width assumption produces under 0.6px for a narrow canvas, which is the bug.

uiScale normalised stroke width against a hardcoded 800px view. A portrait
corrected image is height-constrained, so the canvas renders far narrower
than that and strokes came out sub-pixel: a 1505x2048 image at 426px wide
gave a 0.53px stroke at 40% opacity, invisible over a photo. The step tells
you to click the outlines and keeps the save button disabled until you do,
so the flow dead-ended.

Derive uiScale from the measured rendered width instead, so one unit is one
CSS pixel. Raise unselected stroke opacity and paint a dark halo underneath
so outlines stay legible against arbitrary backgrounds.

Fixes #185

Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
The scale calculation was inline in PolygonEditor with no way to assert it.
Move it to viewbox alongside the other viewBox maths and pin the behaviour:
one unit renders as one CSS pixel, holds across zoom levels and image
aspects, falls back to the fixed width before the render is measured, and
never returns zero or negative.

The regression test asserts the old fixed-width assumption produces under
0.6px for a narrow canvas, which is the bug in #185.

Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
@jasonmadigan
jasonmadigan merged commit 9a31ac2 into main Aug 19, 2026
4 checks passed
@jasonmadigan
jasonmadigan deleted the fix/polygon-outline-visibility branch August 19, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet
4A63

Development

Successfully merging this pull request may close these issues.

Traced outlines are invisible on the Select Tools step

1 participant

0