The CSS tranform property always returns the value of the matrix, since rotation, skew, scale, etc. It is simply a shorthand to facilitate the work and does not require calculating the matrix value every time, however, the matrix is ββcalculated by the browser and applied as a matrix, and when this is done, it will no longer be able to return the rotated degree by an angle without recounting the matrix back.
To make such calculations easier, there is a javascript library called Sylvester , which was created with the goal of simply computing the matrix, try looking at what to get the degree of rotation from the matrix value.
Also, if you want to write a rotation function in javascript to translate degrees of rotation into a matrix, it will probably look something like this (it uses a sylvester for the last calculation):
var Transform = { rotate: function(deg) { var rad = parseFloat(deg) * (Math.PI/180), cos_theta = Math.cos(rad), sin_theta = Math.sin(rad); var a = cos_theta, b = sin_theta, c = -sin_theta, d = cos_theta; return $M([ [a, c, 0], [b, d, 0], [0, 0, 1] ]); } };
Now all you really need to do is reverse modify this function and you are golden :-)
adeneo Nov 25 '11 at 16:12 2011-11-25 16:12
source share