function transformStyleAsMatrix(transformStyle) {
  // Deal with arbitrary transforms:
  var result = [1, 0, 0, 1], ops = [], args = [],
      pat = /(?:^\s*|)(\w*)\s*\(([^)]*)\)\s*/g,
      unknown = transformStyle.replace(pat, function(m) {
        ops.push(m[1].toLowerCase());
        args.push($.map(m[2].split(','), function(s) {
          var v = s.trim().toLowerCase();
          return {
            num: parseFloat(v),
            unit: v.replace(/^[+-.\de]*/, '')
          };
        }));
        return '';
      });
  if (unknown) { return null; }
  for (var index = ops.length - 1; index >= 0; --index) {
    var m = null, a, c, s, t;
    var op = ops[index];
    var arg = args[index];
    if (op == 'matrix') {
      if (arg.length >= 6) {
        m = [arg[0].num, arg[1].num, arg[2].num, arg[3].num,
             arg[4].num, arg[5].num];
      }
    } else if (op == 'rotate') {
      if (arg.length == 1) {
        a = convertToRadians(arg[0]);
        c = Math.cos(a);
        s = Math.sin(a);
        m = [c, -s, c, s];
      }
    } else if (op == 'translate' || op == 'translatex' || op == 'translatey') {
      var tx = 0, ty = 0;
      if (arg.length >= 1) {
        if (arg[0].unit && arg[0].unit != 'px') { return null; } // non-pixels
        if (op == 'translate' || op == 'translatex') { tx = arg[0].num; }
        else if (op == 'translatey') { ty = arg[0].num; }
        if (op == 'translate' && arg.length >= 2) {
          if (arg[1].unit && arg[1].unit != 'px') { return null; }
          ty = arg[1].num;
        }
        m = [0, 0, 0, 0, tx, ty];
      }
    } else if (op == 'scale' || op == 'scalex' || op == 'scaley') {
      var sx = 1, sy = 1;
      if (arg.length >= 1) {
        if (op == 'scale' || op == 'scalex') { sx = arg[0].num; }
        else if (op == 'scaley') { sy = arg[0].num; }
        if (op == 'scale' && arg.length >= 2) { sy = arg[1].num; }
        m = [sx, 0, 0, sy, 0, 0];
      }
    } else if (op == 'skew' || op == 'skewx' || op == 'skewy') {
      var kx = 0, ky = 0;
      if (arg.length >= 1) {
        if (op == 'skew' || op == 'skewx') {
          kx = Math.tan(convertToRadians(arg[0]));
        } else if (op == 'skewy') {
          ky = Math.tan(convertToRadians(arg[0]));
        }
        if (op == 'skew' && arg.length >= 2) {
          ky = Math.tan(convertToRadians(arg[0]));
        }
        m = [1, ky, kx, 1, 0, 0];
      }
    } else {
      // Unrecgonized transformation.
      return null;
    }
    result = matrixProduct(result, m);
  }
  return result;
}
// Applies the css 2d transforms specification.
Applies the css 2d transforms specification.
Applies the css 2d transforms specification .
function transformStyleAsMatrix(transformStyle) {
  var result = [1, 0, 0, 1], ops = [], args = [],
      pat = /(?:^\s*|)(\w*)\s*\(([^)]*)\)\s*/g,
      unknown = transformStyle.replace(pat, function(m) {
        ops.push(m[1].toLowerCase());
        args.push($.map(m[2].split(','), function(s) {
          var v = s.trim().toLowerCase();
          return {
            num: parseFloat(v),
            unit: v.replace(/^[+-.\de]*/, '')
          };
        }));
        return '';
      });
  if (unknown) { return null; }
  for (var index = ops.length - 1; index >= 0; --index) {
    var m = null, a, c, s, t;
    var op = ops[index];
    var arg = args[index];
    if (op == 'matrix') {
      if (arg.length >= 6) {
        m = [arg[0].num, arg[1].num, arg[2].num, arg[3].num,
             arg[4].num, arg[5].num];
      }
    } else if (op == 'rotate') {
      if (arg.length == 1) {
        a = convertToRadians(arg[0]);
        c = Math.cos(a);
        s = Math.sin(a);
        m = [c, -s, c, s];
      }
    } else if (op == 'translate' || op == 'translatex' || op == 'translatey') {
      var tx = 0, ty = 0;
      if (arg.length >= 1) {
        if (arg[0].unit && arg[0].unit != 'px') { return null; } 
        if (op == 'translate' || op == 'translatex') { tx = arg[0].num; }
        else if (op == 'translatey') { ty = arg[0].num; }
        if (op == 'translate' && arg.length >= 2) {
          if (arg[1].unit && arg[1].unit != 'px') { return null; }
          ty = arg[1].num;
        }
        m = [0, 0, 0, 0, tx, ty];
      }
    } else if (op == 'scale' || op == 'scalex' || op == 'scaley') {
      var sx = 1, sy = 1;
      if (arg.length >= 1) {
        if (op == 'scale' || op == 'scalex') { sx = arg[0].num; }
        else if (op == 'scaley') { sy = arg[0].num; }
        if (op == 'scale' && arg.length >= 2) { sy = arg[1].num; }
        m = [sx, 0, 0, sy, 0, 0];
      }
    } else if (op == 'skew' || op == 'skewx' || op == 'skewy') {
      var kx = 0, ky = 0;
      if (arg.length >= 1) {
        if (op == 'skew' || op == 'skewx') {
          kx = Math.tan(convertToRadians(arg[0]));
        } else if (op == 'skewy') {
          ky = Math.tan(convertToRadians(arg[0]));
        }
        if (op == 'skew' && arg.length >= 2) {
          ky = Math.tan(convertToRadians(arg[0]));
        }
        m = [1, ky, kx, 1, 0, 0];
      }
    } else {
      return null;
    }
    result = matrixProduct(result, m);
  }
  return result;
}
function transformStyleAsMatrix ( transformStyle ) { var result = [ 1 , 0 , 0 , 1 ] , ops = [ ] , args = [ ] , pat = / (?:^\s*|)(\w*)\s*\(([^)]*)\)\s* / g , unknown = transformStyle . replace ( pat , function ( m ) { ops . push ( m [ 1 ] . toLowerCase ( ) ) ; args . push ( $ . map ( m [ 2 ] . split ( ',' ) , function ( s ) { var v = s . trim ( ) . toLowerCase ( ) ; return { num : parseFloat ( v ) , unit : v . replace ( / ^[+-.\de]* / , '' ) } ; } ) ) ; return '' ; } ) ; if ( unknown ) { return null ; } for ( var index = ops . length - 1 ; index >= 0 ; -- index ) { var m = null , a , c , s , t ; var op = ops [ index ] ; var arg = args [ index ] ; if ( op == 'matrix' ) { if ( arg . length >= 6 ) { m = [ arg [ 0 ] . num , arg [ 1 ] . num , arg [ 2 ] . num , arg [ 3 ] . num , arg [ 4 ] . num , arg [ 5 ] . num ] ; } } else if ( op == 'rotate' ) { if ( arg . length == 1 ) { a = convertToRadians ( arg [ 0 ] ) ; c = Math . cos ( a ) ; s = Math . sin ( a ) ; m = [ c , - s , c , s ] ; } } else if ( op == 'translate' || op == 'translatex' || op == 'translatey' ) { var tx = 0 , ty = 0 ; if ( arg . length >= 1 ) { if ( arg [ 0 ] . unit && arg [ 0 ] . unit != 'px' ) { return null ; } if ( op == 'translate' || op == 'translatex' ) { tx = arg [ 0 ] . num ; } else if ( op == 'translatey' ) { ty = arg [ 0 ] . num ; } if ( op == 'translate' && arg . length >= 2 ) { if ( arg [ 1 ] . unit && arg [ 1 ] . unit != 'px' ) { return null ; } ty = arg [ 1 ] . num ; } m = [ 0 , 0 , 0 , 0 , tx , ty ] ; } } else if ( op == 'scale' || op == 'scalex' || op == 'scaley' ) { var sx = 1 , sy = 1 ; if ( arg . length >= 1 ) { if ( op == 'scale' || op == 'scalex' ) { sx = arg [ 0 ] . num ; } else if ( op == 'scaley' ) { sy = arg [ 0 ] . num ; } if ( op == 'scale' && arg . length >= 2 ) { sy = arg [ 1 ] . num ; } m = [ sx , 0 , 0 , sy , 0 , 0 ] ; } } else if ( op == 'skew' || op == 'skewx' || op == 'skewy' ) { var kx = 0 , ky = 0 ; if ( arg . length >= 1 ) { if ( op == 'skew' || op == 'skewx' ) { kx = Math . tan ( convertToRadians ( arg [ 0 ] ) ) ; } else if ( op == 'skewy' ) { ky = Math . tan ( convertToRadians ( arg [ 0 ] ) ) ; } if ( op == 'skew' && arg . length >= 2 ) { ky = Math . tan ( convertToRadians ( arg [ 0 ] ) ) ; } m = [ 1 , ky , kx , 1 , 0 , 0 ] ; } } else { return null ; } result = matrixProduct ( result , m ) ; } return result ; }
Applies the css 2d transforms specification.
Applies the css 2d transforms specification .
// Deal with arbitrary transforms: // non-pixels // Unrecgonized transformation.