Skip to content

Commit

Permalink
fix(convertPathData): account for error in z conversions (#1842)
Browse files Browse the repository at this point in the history
  • Loading branch information
KTibow committed Nov 28, 2023
1 parent 3f2bcb4 commit 86d5040
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
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

0 comments on commit 86d5040

Please sign in to comment.