Repository navigation
fix: make traced outlines visible on the select tools step - #187
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #185.
Problem
uiScalenormalised 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 offuiScalecame out proportionally too small.Measured on a 1505x2048 corrected image at a normal laptop viewport:
uiScalestrokeWidthon screenA 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
uiScalefrom the measured rendered width (fitted.width) instead ofBASE_VIEW_WIDTH, so one unit is one CSS pixel at zoom 1.BASE_VIEW_WIDTHstays as the fallback until the size has been measured.Side effect worth knowing
uiScalealso 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 --noEmitclean.eslintclean on all three changed files. Repo warning count unchanged.next buildsucceeds.vitest run: 9 files, 105 tests pass, up from 99. The 5 jsdom module-resolution errors reproduce onmainwith 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.Tests
The scale calculation was inline in the component with no way to assert it, so the second commit moves it to
viewbox.tsasuiScaleForand pins the behaviour:Plus a direct regression test: the old fixed-width assumption produces under 0.6px for a narrow canvas, which is the bug.