Repository navigation
fix: handle strokes wider than the shape in Ellipse.strokeContains - #12185
Merged
Zyie merged 3 commits intoSep 16, 2026
Merged
Conversation
Ellipse.strokeContains derives the unstroked interior by subtracting the inward part of the stroke from each half-axis, at lines 212 and 213 of src/maths/shapes/Ellipse.ts, with nothing holding the result at zero. Lines 221 and 222 then square those half-axes, so a negative one comes back as a smaller positive ellipse, and line 227 excludes every point inside that phantom ellipse from the stroke. That punches a hole through the middle of a stroke which has no hole. Ellipse(0, 0, 10, 10).strokeContains(0, 0, 40, 1) returned false, and so did every other point in the shape, while Circle(0, 0, 10) and the equivalent Rectangle return true throughout for the same stroke. Sampling a 141 by 141 grid at 0.5 spacing across that circle, the ellipse and the circle disagreed at 1257 points for a stroke of 20 at alignment 1, and at 5025 points for a stroke of 40 at alignment 0.75. The one caller in src is GraphicsContext.containsPoint, so a thickly stroked ellipse stopped answering pointer hit tests across its middle. strokeContains now tests the outer edge first and returns true for any point inside it once either inner half-axis has reached zero or less, which is the conclusion Rectangle.strokeContains already reaches, its inner rectangle having inverted and so excluding nothing. Points where both inner half-axes stay positive take exactly the path they took before, and at alignment 0 the inward part of the stroke is always zero, so that alignment cannot reach the new branch at all.
MaxFreedomPollard
requested review from
GoodBoyDigital,
Zyie and
bigtimebuddy
as code owners
September 6, 2026 01:26
commit: |
Zyie
approved these changes
Sep 16, 2026
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.
Overview
Ellipse.strokeContainssubtracted the inward part of the stroke from each half-axis without clamping at zero. Squaring a negative half-axis revived it as a smaller positive ellipse, so a stroke wider than the shape excluded a phantom interior andGraphics.containsPointreturnedfalseacross the middle of a thickly stroked ellipse.Circle,RectangleandRoundedRectanglealready treat this case as fully stroked; this bringsEllipsein line.The method now tests the outer edge first and, once either inner half-axis has reached zero or less, treats every point inside the outer edge as stroked. Points where both inner half-axes stay positive follow the same arithmetic as before, and alignment
0never reaches the new branch.Fixes
Ellipse.strokeContains(and thereforeGraphics.containsPoint) reports the whole interior as stroked when the stroke is wider than the shape, instead of punching a hole through the middlePre-Merge Checklist