fix: 旋转从 CSS matrix 提取角度 + convert-browser.js 同步
This commit is contained in:
+8
-2
@@ -851,11 +851,17 @@ async function convert(input) {
|
||||
shapeOpts.rectRadius = Math.max(...brCorners);
|
||||
}
|
||||
|
||||
// 旋转(CSS transform: rotate)
|
||||
// 旋转(CSS transform: rotate 或 matrix)
|
||||
if (n.styles.transform && n.styles.transform !== 'none') {
|
||||
var rotateMatch = n.styles.transform.match(/rotate\(([\d.]+)deg\)/);
|
||||
var rotateMatch = n.styles.transform.match(/rotate\(([-\d.]+)deg\)/);
|
||||
if (rotateMatch) {
|
||||
shapeOpts.rotate = parseFloat(rotateMatch[1]);
|
||||
} else {
|
||||
var matrixMatch = n.styles.transform.match(/matrix\(([-\d.]+),\s*([-\d.]+),\s*([-\d.]+),\s*([-\d.]+)/);
|
||||
if (matrixMatch) {
|
||||
var angle = Math.round(Math.atan2(parseFloat(matrixMatch[2]), parseFloat(matrixMatch[1])) * 180 / Math.PI);
|
||||
if (angle !== 0) shapeOpts.rotate = angle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user