Skip to content
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(convertPathData): account for error in z conversions #1842

Merged
merged 7 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions plugins/convertPathData.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,12 @@ function filters(
(isSafeToUseZ || next?.command === 'Z' || next?.command === 'z') &&
(command === 'l' || command === 'h' || command === 'v')
) {
// @ts-ignore
if (pathBase[0] === item.coords[0] && pathBase[1] === item.coords[1]) {
if (
// @ts-ignore
Math.abs(pathBase[0] - item.coords[0]) < error &&
// @ts-ignore
Math.abs(pathBase[1] - item.coords[1]) < error
) {
command = 'z';
data = [];
}
Expand Down Expand Up @@ -839,9 +843,9 @@ function filters(
params.removeUseless &&
isSafeToUseZ &&
// @ts-ignore
item.base[0] === item.coords[0] &&
Math.abs(item.base[0] - item.coords[0]) < error / 10 &&
// @ts-ignore
item.base[1] === item.coords[1]
Math.abs(item.base[1] - item.coords[1]) < error / 10
)
return false;

Expand Down
Loading
Loading