Repository navigation
fix: clamp the corner radius in RoundedRectangle.strokeContains - #12333
Merged
Zyie merged 1 commit intoOct 30, 2026
Merged
Conversation
MaxFreedomPollard
requested review from
GoodBoyDigital,
Zyie and
bigtimebuddy
as code owners
October 23, 2026 02:06
commit: |
bigtimebuddy
approved these changes
Oct 23, 2026
RoundedRectangle.strokeContains took this.radius as given, at line 355
of src/maths/shapes/RoundedRectangle.ts. Everything else that handles
the shape clamps it to half of the shorter side first: the WebGL/WebGPU
builder (buildCircle.ts line 69), the canvas renderer's
buildRoundedRectPath, and RoundedRectangle.contains at line 296. The
radius property's own docs say it is "Automatically clamped to half of
smallest dimension".
With an oversized radius, innerWidth and innerHeight go negative, the
straight-edge checks stop matching, and the corner arcs are centered
outside the drawn shape. roundRect(0, 0, 100, 40, 50).stroke({ width: 4 })
is drawn as a pill with radius 20, but strokeContains returned false on
its straight edges and at both ends, e.g. (30, 0) and (0, 20), and true
at (20, 10), which is inside the fill. The default radius of 20 takes
the same path on any shape whose shorter side is under 40. The caller is
GraphicsContext.containsPoint, so pointer hit tests on stroked rounded
rectangles followed an outline that was never drawn.
strokeContains now clamps the radius with the same expression as
contains. A radius that is already in range is unchanged, so results for
those shapes stay exactly as they were.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Zyie
force-pushed
the
fix/rounded-rect-stroke-radius
branch
2 times, most recently
from
October 30, 2026 22:19
beeed12 to
f4ff04a
Compare
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.
Description of change
RoundedRectangle.strokeContainsusedradiusexactly as given. Everything else that handles the shape clamps it to half of the shorter side first: the WebGL/WebGPU builder (buildRoundedRectangle), the canvas renderer'sbuildRoundedRectPath, andRoundedRectangle.contains. Theradiusdocs also say it is "Automatically clamped to half of smallest dimension". With an oversized radius,innerWidth/innerHeightwent negative, the straight-edge checks stopped matching, and the corner arcs were centered outside the drawn shape, so stroke hit tests (Graphics.containsPoint, pointer events) followed an outline that is never drawn.The default radius of 20 hits the same path on any rounded rectangle whose shorter side is under 40, e.g.
roundRect(0, 0, 30, 30).strokeContainsnow clamps the radius with the same expression ascontains. A radius that is already in range is unchanged, so results for those shapes are identical.Verification
RoundedRectangle.test.ts(radius 20, 50 and 1000 on a 100x40 rectangle must give the same hits) and inGraphics.Bounds.test.tsthroughGraphics.containsPoint, next to the existing ellipse stroke tests. Both fail ondevand pass with the fix. I ran those two files and the other shape tests insrc/maths/__tests__(Circle, Ellipse, Polygon, Rectangle, Triangle) under Node 22 with a small jest-compatible shim, not the fullnpm testsuite.strokeContainswith the trianglesbuildLineemits for the stroke, on a 0.5px grid inside the hit-test bounds (skipping points within 0.6px of the mesh edge).roundRect(0, 0, 100, 40, 50)with width 4 disagreed at 4802 of 16297 points before and 0 after;roundRect(0, 0, 30, 30)at 648 of 3957 before and 0 after; alignment 0 and 1 also agree everywhere after. An in-range radius (roundRect(0, 0, 100, 100, 10), width 20) agreed at every point both before and after.Pre-Merge Checklist
npm run lint)npm run test)🤖 Generated with Claude Code