Skip to content

Commit

Permalink
Fix 180deg ‘convertTransform’
Browse files Browse the repository at this point in the history
Fix NaN after Math.acos due to error making illegal value out of bounds
Fix #1101
  • Loading branch information
GreLI committed Jul 14, 2019
1 parent 8671c4c commit e1dd31c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugins/_transforms.js
Expand Up @@ -153,7 +153,8 @@ exports.matrixToTransform = function(transform, params) {
sy = (data[3] < 0 ? -1 : 1) * Math.hypot(data[1], data[3]);
transforms.push({ name: 'scale', data: [sx, sy] });
}
var rotate = [mth.acos(data[0] / sx, floatPrecision) * ((scaleBefore ? 1 : sy) * data[1] < 0 ? -1 : 1)];
var angle = Math.min(Math.max(-1, data[0] / sx), 1),
rotate = [mth.acos(angle, floatPrecision) * ((scaleBefore ? 1 : sy) * data[1] < 0 ? -1 : 1)];

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

Expand Down
2 changes: 2 additions & 0 deletions test/plugins/convertTransform.03.svg
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 e1dd31c

Please sign in to comment.