css-to-mat4
mat4-css-parse
deprecated in favour ofConverts a matrix string like "matrix(1, 0, 0, 1, 0, 0)"
or "matrix3d(...)"
into a 4x4 matrix (flat array).
Simple example:
var parse = var str = 'matrix(0, 0, 1, 0, 0, 1)' var mat = console // -> 16console // -> true
Letting the browser compute a matrix from a list of CSS transforms:
var style = var parse = var getPrefix = var prefix = if prefix //transforms supported //apply some transforms with a complex CSS string //get computed style, which will be a flat matrix or matrix3d string var str = windowprefix //parse as a 4x4 matrix var mat = //do something with your matrix
Usage
toMat4(str[, out])
Converts the "matrix()"
or `"matrix3d()" string into a 16-float array representing a 4x4 matrix. 2D matrices will be stored in the upper left of a 4x4 identity matrix.
You can specify an out
matrix parameter, otherwise it will create a new 16-length array.
License
MIT, see LICENSE.md for details.