Fix zero-step SVG arc rendering for thin strokes in turtle-painter#5901
Open
kartikktripathi wants to merge 1 commit intosugarlabs:masterfrom
Open
Fix zero-step SVG arc rendering for thin strokes in turtle-painter#5901kartikktripathi wants to merge 1 commit intosugarlabs:masterfrom
kartikktripathi wants to merge 1 commit intosugarlabs:masterfrom
Conversation
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Contributor
Author
|
Hey @walterbender, this PR is ready to be reviewed. It fixes the incorrect use of |
Contributor
mahesh-09-12
left a comment
There was a problem hiding this comment.
@kartikktripathi nice catch here, the previous Math.floor(savedStroke, 1) usage was incorrect and could result in zero steps for thin strokes. Clamping the computed value with Math.max(..., 1) makes the SVG arc rendering more robust and prevents subtle visual issues. The change is minimal and applied consistently.
Contributor
Author
|
Thanks for the review, Mahesh! |
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.
Summary
This PR fixes an incorrect use of
Math.floor()inturtle-painter.jsthat allowed arc step calculations to become zero for thin stroke values. This silently broke SVG arc cap rendering for hollow lines and bezier curves.Changes
Corrected improper
Math.floorusage where the minimum guard was mistakenly passed as a second argument:Before:
const steps = Math.max(Math.floor(savedStroke, 1));
After:
const steps = Math.max(Math.floor(savedStroke), 1);
Applied the same fix consistently in all four affected locations:
This ensures that
stepsis always at least1, preventing_svgArc()from receiving0steps.Testing
Note
Math.floor(x, 1)ignores the second argument in JavaScript. The previous implementation effectively allowedstepsto become0, causing silent rendering issues. This fix enforces the intended minimum guard correctly.