ag-psd
ag-psd copied to clipboard
how to read the rotation of layer?
I read the readme_psd.md,failed to find where to get to rotaion of a layer,can you help me?
I don't think this value is stored anywhere in PSD file, it's calculated back from the transform (placedLayer.transform
) that specifies location of 4 corners of transformation cage.
hello, transform= [12391.430367826988, 1721.516648354885, 2447.364078652975, 8802.809486322956, -70.25686706304622, 5075.064425643115, 9873.809422110964, -2006.2284123249551];) The four corners, how to calculate the rotation Angle, can provide the code to calculate the Angle?
The following is my code, but the calculation will be a little error, can you help me to see what went wrong?
const angle = getAngle({ x: 0, y: img.height, }, { x: transform[6] - transform[0], y: transform[7] - transform[1], });
function getAngle({x: x1, y: y1}, {x: x2, y: y2}) { const dot = x1 * x2 + y1 * y2 const det = x1 * y2 - y1 * x2 const angle = Math.atan2(det, dot) / Math.PI * 180 return angle }