I found the relative transformation matrix in the figma file API is confusing in the shear situation . And i don’t know how to get the shear info from this abnormal transformation matrix.
The API documentation said it is a 2x3 affine transformation matrix that can be used to calculate the affine transforms applied to a layer, including scaling, rotation, shearing, and translation. As I know, a normal transform matrix (ignore translation) for a shear in x-direction is:
If we only do the shear transformation with a angle of 45 deg in x-direction, the matrix is expected to be:
However, the matrix obtained from the figma API is not in that form. The element m (indexed from zero) is \sqrt(2)/2 other than 1. I wonder if the transformation matrix is calculated wrong .
Here is the reproduction process:
- draw a rectangle in a figma file and shear it in the x direction for 45 degrees, i.e. dUm14EjdHK6J8tcfbgwbss
- call the figma restful API, i.e. v1/files/dUm14EjdHK6J8tcfbgwbss?ids=0:1&geometry=paths
- we got the confusing transformation matrix: