Skip to content

Commit

Permalink
Fixed sign losing in scale matrix. Fixes #513
Browse files Browse the repository at this point in the history
  • Loading branch information
GreLI committed Mar 8, 2016
1 parent 0b23ff6 commit 9b84827
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
7 changes: 3 additions & 4 deletions plugins/_transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,11 @@ exports.matrixToTransform = function(transform, params) {
// [sx·cos(a), sy·sin(a), sx·-sin(a), sy·cos(a), x, y] → scale(sx, sy)·rotate(a[, cx, cy]) (if !scaleBefore)
} else if (!colsSum || (sx == 1 && sy == 1) || !scaleBefore) {
if (!scaleBefore) {
sx = Math.sqrt(data[0] * data[0] + data[2] * data[2]);
sy = Math.sqrt(data[1] * data[1] + data[3] * data[3]);
sx = (data[0] < 0 ? -1 : 1) * Math.sqrt(data[0] * data[0] + data[2] * data[2]);
sy = (data[3] < 0 ? -1 : 1) * Math.sqrt(data[1] * data[1] + data[3] * data[3]);
transforms.push({ name: 'scale', data: [sx, sy] });
}
var a1 = mth.acos(data[0] / sx, floatPrecision),
rotate = [a1.toFixed(floatPrecision) * (data[1] < 0 ? -1 : 1)];
var rotate = [mth.acos(data[0] / sx, floatPrecision) * (data[1] * sy < 0 ? -1 : 1)];

if (rotate[0]) transforms.push({ name: 'rotate', data: rotate });

Expand Down
16 changes: 16 additions & 0 deletions test/plugins/convertTransform.01.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9b84827

Please sign in to comment.