-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: useless path collapsing for segments that are not start and end #1755
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -766,11 +766,18 @@ function filters(path, params, { maybeHasStrokeAndLinecap, hasMarkerMid }) { | |||||||||||||||||||||
} | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
// remove useless non-first path segments | ||||||||||||||||||||||
if (params.removeUseless && !maybeHasStrokeAndLinecap) { | ||||||||||||||||||||||
// l 0,0 / h 0 / v 0 / q 0,0 0,0 / t 0,0 / c 0,0 0,0 0,0 / s 0,0 0,0 | ||||||||||||||||||||||
// remove useless non-start/end path segments | ||||||||||||||||||||||
var isStart = !path[index - 1] || path[index - 1].command === 'm'; | ||||||||||||||||||||||
var isEnd = !path[index + 1] || path[index + 1].command === 'm'; | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand what I'm reading correctly, this current version doesn't remove move statements at the very end of the path, which are completely useless. It should. |
||||||||||||||||||||||
if ( | ||||||||||||||||||||||
params.removeUseless && | ||||||||||||||||||||||
!hasMarkerMid && | ||||||||||||||||||||||
(!maybeHasStrokeAndLinecap || !(isStart || isEnd)) | ||||||||||||||||||||||
) { | ||||||||||||||||||||||
Comment on lines
+772
to
+776
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't make sense as these do fundamentally different things. *I would personally write this as |
||||||||||||||||||||||
// m 0,0 / l 0,0 / h 0 / v 0 / q 0,0 0,0 / t 0,0 / c 0,0 0,0 0,0 / s 0,0 0,0 | ||||||||||||||||||||||
if ( | ||||||||||||||||||||||
(command === 'l' || | ||||||||||||||||||||||
(command === 'm' || | ||||||||||||||||||||||
command === 'l' || | ||||||||||||||||||||||
command === 'h' || | ||||||||||||||||||||||
command === 'v' || | ||||||||||||||||||||||
command === 'q' || | ||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be
command === 'm'
, not testing if the previous one ism
?