Skip to content

Commit fa3a7bd

Browse files
committed
fix(convertPathData): use relSubpoint instead of item.coords when
fitting
1 parent 9e2029f commit fa3a7bd

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

plugins/convertPathData.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -877,10 +877,8 @@ function filters(
877877
(command === 'l' || command === 'h' || command === 'v')
878878
) {
879879
if (
880-
// @ts-expect-error
881-
Math.abs(pathBase[0] - item.coords[0]) < error &&
882-
// @ts-expect-error
883-
Math.abs(pathBase[1] - item.coords[1]) < error
880+
Math.abs(pathBase[0] - relSubpoint[0]) < error &&
881+
Math.abs(pathBase[1] - relSubpoint[1]) < error
884882
) {
885883
command = 'z';
886884
data = [];
@@ -918,7 +916,7 @@ function filters(
918916
prevQControlPoint = reflectPoint(qControlPoint, item.base);
919917
} else {
920918
// @ts-expect-error
921-
prevQControlPoint = item.coords;
919+
prevQControlPoint = relSubpoint.slice();
922920
}
923921
} else {
924922
prevQControlPoint = undefined;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Proper, post-rounding coordinate system (1, 1), not pre-rounding (0.8, 0.8), should be used when converting going home to z
2+
3+
===
4+
5+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
6+
<path d="M 0 0 l 0.4 0.4 l 0.4 0.4" />
7+
</svg>
8+
9+
@@@
10+
11+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
12+
<path d="m0 0 1 1"/>
13+
</svg>
14+
15+
@@@
16+
17+
{ "floatPrecision": 0 }

0 commit comments

Comments
 (0)