Repository navigation
Conversation
A negative corner radius reached context.arcTo(), which throws for a negative radius, aborting the layer draw. Clamp each corner radius to 0, as rounded rects and Tag already do.
Member
|
THanks |
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.
A
RegularPolygonwith a negativecornerRadius(a number or an entry of the per-corner array) throws while drawing:The error is thrown inside the layer draw, so any shapes after the polygon aren't drawn either, and the hit graph throws in the same way. Since the negative radius fix in 806dbec,
RectandTagdraw a negativecornerRadiusas no rounding.RegularPolygon, however, goes throughUtil.drawRoundedPolygonPath(), which passes the negative value on tocontext.arcTo().drawRoundedPolygonPath()now clamps each corner radius to 0 before scaling it, so a negative corner draws sharp, the same as0.The new test in
RegularPolygon-test.tsdraws polygons withcornerRadius: -10and[-5, 10, -5, 10, -5]and compares them with0and[0, 10, 0, 10, 0]. Without the change it fails withRangeError: Radius value must be positiveon skia, and the drawing differs on node-canvas. These all pass:npm run test:node:canvas(1285 passing)npm run test:node:skia(1288 passing)npm run test:typestsc --noEmit