Skip to content

Instantly share code, notes, and snippets.

@steckel
Created December 16, 2011 00:40
Show Gist options
  • Save steckel/1483792 to your computer and use it in GitHub Desktop.
Save steckel/1483792 to your computer and use it in GitHub Desktop.
Simple prototype function for String objects to take a CSS transformation string and return a CSSMatrix3d string.
String::toCSSMatrix3d = ->
webKitCSSMatrix = new WebKitCSSMatrix @
matrix3d = "matrix3d(#{webKitCSSMatrix.m11},#{webKitCSSMatrix.m12},#{webKitCSSMatrix.m13},#{webKitCSSMatrix.m14},#{webKitCSSMatrix.m21},#{webKitCSSMatrix.m22},#{webKitCSSMatrix.m23},#{webKitCSSMatrix.m24},#{webKitCSSMatrix.m31},#{webKitCSSMatrix.m32},#{webKitCSSMatrix.m33},#{webKitCSSMatrix.m34},#{webKitCSSMatrix.m41},#{webKitCSSMatrix.m42},#{webKitCSSMatrix.m43},#{webKitCSSMatrix.m44})"
matrix3d
console.log "scale3d(2, 2, 0) translate3d(-454px, 0px, 0px) rotate(1deg)".toCSSMatrix3d()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment