Bug in Path.transform breaks Path rotation
hauswirth opened this issue · 0 comments
hauswirth commented
When rotating a Path with Path.rotate(angle)
, the resulting path is distorted.
Lines 202 to 208 in 417af0c
The cause is that the arrow function which Point.transform
passes to Point.mapPoints
modifies the value of its parameter x
(which should hold the x-coordinate of the original point), and then uses the modified x
(instead of using the original x
) to compute the y-coordinate of the transformed point in its second line.
The fix is straightforward: e.g., introduce variables tx
and ty
for the transformed point:
return this.mapPoints((x, y) => {
const tx = m0 * x + m2 * y + m4;
const ty = m1 * x + m3 * y + m5;
return [tx, ty];
});