Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there js plugin convert the matrix parameter to css3 transform property?

Suppose I have css3 transform style:

img
{
   -webkit-transform:rotate(10deg) translate(100px,20px);
   -moz-transform:rotate(10deg) translate(100px,20px);
}

then I use jquery get it style:

console.log($('#clone').css('-moz-transform'));

it only return me a series number:

matrix(0.984808, 0.173648, -0.173648, 0.984808, 95.0078px, 37.061px)

Is there a js plugin which could turn the matrix number to the transform?Or turn to the other side?

like image 667
hh54188 Avatar asked Mar 22 '12 08:03

hh54188


1 Answers

Numbers you're getting are the result of multiplying Rotation and Translation matrices.

Although for your case you could get by easily by doing the math on paper and getting the formulas you need by hand, for increasing number of terms it would be a teadious task (you need to know the structure of original trasforms in order to reverse them as well).

Here's a link that will help you:

http://www.useragentman.com/blog/2011/01/07/css3-matrix-transform-for-the-mathematically-challenged/

Why not just set those value you need from Javascript code and therefore eliminate need for geting them from matrix at all?

like image 58
Alex Avatar answered Sep 30 '22 16:09

Alex