New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

transformation-matrix

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

transformation-matrix - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

build-commonjs/fromTransformAttribute.autogenerated.js

2

build-commonjs/fromString.js

@@ -11,3 +11,3 @@ "use strict";

*/
var matrixRegex = /^matrix\(\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*\)$/i;
var matrixRegex = /^matrix\(\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*\)$/i;

@@ -14,0 +14,0 @@ /**

@@ -5,3 +5,3 @@ /**

*/
var matrixRegex = /^matrix\(\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*\)$/i;
var matrixRegex = /^matrix\(\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*\)$/i;

@@ -8,0 +8,0 @@ /**

@@ -10,3 +10,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

root["TransformationMatrix"] = factory();
})(typeof self !== 'undefined' ? self : this, function() {
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap

@@ -58,2 +58,7 @@ /******/ // The module cache

/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules

@@ -74,4 +79,5 @@ /******/ __webpack_require__.n = function(module) {

/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 3);
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })

@@ -84,134 +90,6 @@ /************************************************************************/

"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = isUndefined;
function isUndefined(val) {
return typeof val === 'undefined';
}
__webpack_require__.r(__webpack_exports__);
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = translate;
// CONCATENATED MODULE: ./src/applyToPoint.js
/**
* Calculate a translate matrix
* @param tx Translation on axis x
* @param [ty = 0] Translation on axis y
* @returns {{a: number, b: number, c: number, e: number, d: number, f: number}} Affine matrix
*/
function translate(tx) {
var ty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
return {
a: 1, c: 0, e: tx,
b: 0, d: 1, f: ty
};
}
/***/ }),
/* 2 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = transform;
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); }
/**
* Merge multiple matrices into one
* @param matrices {...object} list of matrices
* @returns {{a: number, b: number, c: number, e: number, d: number, f: number}} Affine matrix
*/
function transform() {
for (var _len = arguments.length, matrices = Array(_len), _key = 0; _key < _len; _key++) {
matrices[_key] = arguments[_key];
}
matrices = Array.isArray(matrices[0]) ? matrices[0] : matrices;
var multiply = function multiply(m1, m2) {
return {
a: m1.a * m2.a + m1.c * m2.b, c: m1.a * m2.c + m1.c * m2.d, e: m1.a * m2.e + m1.c * m2.f + m1.e,
b: m1.b * m2.a + m1.d * m2.b, d: m1.b * m2.c + m1.d * m2.d, f: m1.b * m2.e + m1.d * m2.f + m1.f
};
};
switch (matrices.length) {
case 0:
throw new Error('no matrices provided');
case 1:
return matrices[0];
case 2:
return multiply(matrices[0], matrices[1]);
default:
var _matrices = matrices,
_matrices2 = _toArray(_matrices),
m1 = _matrices2[0],
m2 = _matrices2[1],
rest = _matrices2.slice(2);
var m = multiply(m1, m2);
return transform.apply(undefined, [m].concat(_toConsumableArray(rest)));
}
}
/***/ }),
/* 3 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__applyToPoint__ = __webpack_require__(4);
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "applyToPoint", function() { return __WEBPACK_IMPORTED_MODULE_0__applyToPoint__["a"]; });
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "applyToPoints", function() { return __WEBPACK_IMPORTED_MODULE_0__applyToPoint__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__fromObject__ = __webpack_require__(5);
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "fromObject", function() { return __WEBPACK_IMPORTED_MODULE_1__fromObject__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__fromString__ = __webpack_require__(6);
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "fromString", function() { return __WEBPACK_IMPORTED_MODULE_2__fromString__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__identity__ = __webpack_require__(7);
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return __WEBPACK_IMPORTED_MODULE_3__identity__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__inverse__ = __webpack_require__(8);
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "inverse", function() { return __WEBPACK_IMPORTED_MODULE_4__inverse__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__isAffineMatrix__ = __webpack_require__(9);
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "isAffineMatrix", function() { return __WEBPACK_IMPORTED_MODULE_5__isAffineMatrix__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__rotate__ = __webpack_require__(10);
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "rotate", function() { return __WEBPACK_IMPORTED_MODULE_6__rotate__["a"]; });
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "rotateDEG", function() { return __WEBPACK_IMPORTED_MODULE_6__rotate__["b"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__scale__ = __webpack_require__(11);
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return __WEBPACK_IMPORTED_MODULE_7__scale__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__shear__ = __webpack_require__(12);
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "shear", function() { return __WEBPACK_IMPORTED_MODULE_8__shear__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__toString__ = __webpack_require__(13);
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "toCSS", function() { return __WEBPACK_IMPORTED_MODULE_9__toString__["a"]; });
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "toSVG", function() { return __WEBPACK_IMPORTED_MODULE_9__toString__["b"]; });
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "toString", function() { return __WEBPACK_IMPORTED_MODULE_9__toString__["c"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__transform__ = __webpack_require__(2);
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "transform", function() { return __WEBPACK_IMPORTED_MODULE_10__transform__["a"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__translate__ = __webpack_require__(1);
/* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "translate", function() { return __WEBPACK_IMPORTED_MODULE_11__translate__["a"]; });
/***/ }),
/* 4 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = applyToPoint;
/* harmony export (immutable) */ __webpack_exports__["b"] = applyToPoints;
/**
* Calculate a point transformed with an affine matrix

@@ -240,9 +118,3 @@ * @param matrix Affine matrix

}
/***/ }),
/* 5 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = fromObject;
// CONCATENATED MODULE: ./src/fromObject.js
/**

@@ -264,9 +136,3 @@ * Extract an affine matrix from an object that contains a,b,c,d,e,f keys

}
/***/ }),
/* 6 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = fromString;
// CONCATENATED MODULE: ./src/fromString.js
/**

@@ -276,3 +142,3 @@ * @ignore

*/
var matrixRegex = /^matrix\(\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*\)$/i;
var matrixRegex = /^matrix\(\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*\)$/i;

@@ -296,9 +162,3 @@ /**

}
/***/ }),
/* 7 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = identity;
// CONCATENATED MODULE: ./src/identity.js
/**

@@ -314,9 +174,3 @@ * Identity matrix

}
/***/ }),
/* 8 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = inverse;
// CONCATENATED MODULE: ./src/inverse.js
/**

@@ -349,9 +203,3 @@ * Calculate a matrix that is the inverse of the provided matrix

}
/***/ }),
/* 9 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = isAffineMatrix;
// CONCATENATED MODULE: ./src/isAffineMatrix.js
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -370,17 +218,71 @@

}
// CONCATENATED MODULE: ./src/utils.js
function isUndefined(val) {
return typeof val === 'undefined';
}
// CONCATENATED MODULE: ./src/translate.js
/**
* Calculate a translate matrix
* @param tx Translation on axis x
* @param [ty = 0] Translation on axis y
* @returns {{a: number, b: number, c: number, e: number, d: number, f: number}} Affine matrix
*/
function translate(tx) {
var ty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
/***/ }),
/* 10 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
return {
a: 1, c: 0, e: tx,
b: 0, d: 1, f: ty
};
}
// CONCATENATED MODULE: ./src/transform.js
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = rotate;
/* harmony export (immutable) */ __webpack_exports__["b"] = rotateDEG;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__translate__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__transform__ = __webpack_require__(2);
function _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); }
/**
* Merge multiple matrices into one
* @param matrices {...object} list of matrices
* @returns {{a: number, b: number, c: number, e: number, d: number, f: number}} Affine matrix
*/
function transform() {
for (var _len = arguments.length, matrices = Array(_len), _key = 0; _key < _len; _key++) {
matrices[_key] = arguments[_key];
}
matrices = Array.isArray(matrices[0]) ? matrices[0] : matrices;
var multiply = function multiply(m1, m2) {
return {
a: m1.a * m2.a + m1.c * m2.b, c: m1.a * m2.c + m1.c * m2.d, e: m1.a * m2.e + m1.c * m2.f + m1.e,
b: m1.b * m2.a + m1.d * m2.b, d: m1.b * m2.c + m1.d * m2.d, f: m1.b * m2.e + m1.d * m2.f + m1.f
};
};
switch (matrices.length) {
case 0:
throw new Error('no matrices provided');
case 1:
return matrices[0];
case 2:
return multiply(matrices[0], matrices[1]);
default:
var _matrices = matrices,
_matrices2 = _toArray(_matrices),
m1 = _matrices2[0],
m2 = _matrices2[1],
rest = _matrices2.slice(2);
var m = multiply(m1, m2);
return transform.apply(undefined, [m].concat(_toConsumableArray(rest)));
}
}
// CONCATENATED MODULE: ./src/rotate.js
var cos = Math.cos,

@@ -404,7 +306,7 @@ sin = Math.sin,

};
if (Object(__WEBPACK_IMPORTED_MODULE_0__utils__["a" /* isUndefined */])(cx) || Object(__WEBPACK_IMPORTED_MODULE_0__utils__["a" /* isUndefined */])(cy)) {
if (isUndefined(cx) || isUndefined(cy)) {
return rotationMatrix;
}
return Object(__WEBPACK_IMPORTED_MODULE_2__transform__["a" /* transform */])([Object(__WEBPACK_IMPORTED_MODULE_1__translate__["a" /* translate */])(cx, cy), rotationMatrix, Object(__WEBPACK_IMPORTED_MODULE_1__translate__["a" /* translate */])(-cx, -cy)]);
return transform([translate(cx, cy), rotationMatrix, translate(-cx, -cy)]);
}

@@ -425,12 +327,5 @@

}
// CONCATENATED MODULE: ./src/scale.js
/***/ }),
/* 11 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = scale;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils__ = __webpack_require__(0);
/**

@@ -445,3 +340,3 @@ * Calculate a scaling matrix

if (Object(__WEBPACK_IMPORTED_MODULE_0__utils__["a" /* isUndefined */])(sy)) sy = sx;
if (isUndefined(sy)) sy = sx;
return {

@@ -452,9 +347,3 @@ a: sx, c: 0, e: 0,

}
/***/ }),
/* 12 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = shear;
// CONCATENATED MODULE: ./src/shear.js
/**

@@ -472,11 +361,3 @@ * Calculate a shear matrix

}
/***/ }),
/* 13 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = toCSS;
/* harmony export (immutable) */ __webpack_exports__["b"] = toSVG;
/* harmony export (immutable) */ __webpack_exports__["c"] = toString;
// CONCATENATED MODULE: ./src/toString.js
/**

@@ -488,3 +369,3 @@ * Serialize the matrix to a string that can be used with CSS or SVG

function toCSS(matrix) {
return toString(matrix);
return toString_toString(matrix);
}

@@ -498,3 +379,3 @@

function toSVG(matrix) {
return toString(matrix);
return toString_toString(matrix);
}

@@ -507,6 +388,35 @@

*/
function toString(matrix) {
function toString_toString(matrix) {
return "matrix(" + matrix.a + "," + matrix.b + "," + matrix.c + "," + matrix.d + "," + matrix.e + "," + matrix.f + ")";
}
// CONCATENATED MODULE: ./src/index.js
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "applyToPoint", function() { return applyToPoint; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "applyToPoints", function() { return applyToPoints; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "fromObject", function() { return fromObject; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "fromString", function() { return fromString; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "identity", function() { return identity; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "inverse", function() { return inverse; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "isAffineMatrix", function() { return isAffineMatrix; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "rotate", function() { return rotate; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "rotateDEG", function() { return rotateDEG; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "scale", function() { return scale; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "shear", function() { return shear; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "toCSS", function() { return toCSS; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "toSVG", function() { return toSVG; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "toString", function() { return toString_toString; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "transform", function() { return transform; });
/* concated harmony reexport */__webpack_require__.d(__webpack_exports__, "translate", function() { return translate; });
/***/ })

@@ -513,0 +423,0 @@ /******/ ]);

@@ -1,1 +0,2 @@

!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.TransformationMatrix=r():t.TransformationMatrix=r()}("undefined"!=typeof self?self:this,function(){return function(t){function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var n={};return r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:e})},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},r.p="",r(r.s=3)}([function(t,r,n){"use strict";function e(t){return void 0===t}r.a=e},function(t,r,n){"use strict";function e(t){return{a:1,c:0,e:t,b:0,d:1,f:arguments.length>1&&void 0!==arguments[1]?arguments[1]:0}}r.a=e},function(t,r,n){"use strict";function e(t){if(Array.isArray(t)){for(var r=0,n=Array(t.length);r<t.length;r++)n[r]=t[r];return n}return Array.from(t)}function o(t){return Array.isArray(t)?t:Array.from(t)}function a(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];r=Array.isArray(r[0])?r[0]:r;var u=function(t,r){return{a:t.a*r.a+t.c*r.b,c:t.a*r.c+t.c*r.d,e:t.a*r.e+t.c*r.f+t.e,b:t.b*r.a+t.d*r.b,d:t.b*r.c+t.d*r.d,f:t.b*r.e+t.d*r.f+t.f}};switch(r.length){case 0:throw new Error("no matrices provided");case 1:return r[0];case 2:return u(r[0],r[1]);default:var i=r,c=o(i),f=c[0],s=c[1],d=c.slice(2),p=u(f,s);return a.apply(void 0,[p].concat(e(d)))}}r.a=a},function(t,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var e=n(4);n.d(r,"applyToPoint",function(){return e.a}),n.d(r,"applyToPoints",function(){return e.b});var o=n(5);n.d(r,"fromObject",function(){return o.a});var a=n(6);n.d(r,"fromString",function(){return a.a});var u=n(7);n.d(r,"identity",function(){return u.a});var i=n(8);n.d(r,"inverse",function(){return i.a});var c=n(9);n.d(r,"isAffineMatrix",function(){return c.a});var f=n(10);n.d(r,"rotate",function(){return f.a}),n.d(r,"rotateDEG",function(){return f.b});var s=n(11);n.d(r,"scale",function(){return s.a});var d=n(12);n.d(r,"shear",function(){return d.a});var p=n(13);n.d(r,"toCSS",function(){return p.a}),n.d(r,"toSVG",function(){return p.b}),n.d(r,"toString",function(){return p.c});var l=n(2);n.d(r,"transform",function(){return l.a});var b=n(1);n.d(r,"translate",function(){return b.a})},function(t,r,n){"use strict";function e(t,r){return{x:t.a*r.x+t.c*r.y+t.e,y:t.b*r.x+t.d*r.y+t.f}}function o(t,r){return r.map(function(r){return e(t,r)})}r.a=e,r.b=o},function(t,r,n){"use strict";function e(t){return{a:parseFloat(t.a),b:parseFloat(t.b),c:parseFloat(t.c),d:parseFloat(t.d),e:parseFloat(t.e),f:parseFloat(t.f)}}r.a=e},function(t,r,n){"use strict";function e(t){var r=t.match(o);if(null===r||r.length<7)throw new Error("'"+t+"' is not a matrix");return{a:parseFloat(r[1]),b:parseFloat(r[2]),c:parseFloat(r[3]),d:parseFloat(r[4]),e:parseFloat(r[5]),f:parseFloat(r[6])}}r.a=e;var o=/^matrix\(\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*\)$/i},function(t,r,n){"use strict";function e(){return{a:1,c:0,e:0,b:0,d:1,f:0}}r.a=e},function(t,r,n){"use strict";function e(t){var r=t.a,n=t.b,e=t.c,o=t.d,a=t.e,u=t.f,i=r*o-n*e;return{a:o/i,b:n/-i,c:e/-i,d:r/i,e:(o*a-e*u)/-i,f:(n*a-r*u)/i}}r.a=e},function(t,r,n){"use strict";function e(t){var r=function(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)};return"object"===(void 0===t?"undefined":o(t))&&t.hasOwnProperty("a")&&r(t.a)&&t.hasOwnProperty("b")&&r(t.b)&&t.hasOwnProperty("c")&&r(t.c)&&t.hasOwnProperty("d")&&r(t.d)&&t.hasOwnProperty("e")&&r(t.e)&&t.hasOwnProperty("f")&&r(t.f)}r.a=e;var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t}},function(t,r,n){"use strict";function e(t,r,n){var e=c(t),o=f(t),s={a:e,c:-o,e:0,b:o,d:e,f:0};return Object(a.a)(r)||Object(a.a)(n)?s:Object(i.a)([Object(u.a)(r,n),s,Object(u.a)(-r,-n)])}function o(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return e(t*s/180,r,n)}r.a=e,r.b=o;var a=n(0),u=n(1),i=n(2),c=Math.cos,f=Math.sin,s=Math.PI},function(t,r,n){"use strict";function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return Object(o.a)(r)&&(r=t),{a:t,c:0,e:0,b:0,d:r,f:0}}r.a=e;var o=n(0)},function(t,r,n){"use strict";function e(t,r){return{a:1,c:t,e:0,b:r,d:1,f:0}}r.a=e},function(t,r,n){"use strict";function e(t){return a(t)}function o(t){return a(t)}function a(t){return"matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")"}r.a=e,r.b=o,r.c=a}])});
!function(r,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.TransformationMatrix=t():r.TransformationMatrix=t()}(window,function(){return function(r){var t={};function n(e){if(t[e])return t[e].exports;var o=t[e]={i:e,l:!1,exports:{}};return r[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=r,n.c=t,n.d=function(r,t,e){n.o(r,t)||Object.defineProperty(r,t,{configurable:!1,enumerable:!0,get:e})},n.r=function(r){Object.defineProperty(r,"__esModule",{value:!0})},n.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(t,"a",t),t},n.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},n.p="",n(n.s=0)}([function(r,t,n){"use strict";function e(r,t){return{x:r.a*t.x+r.c*t.y+r.e,y:r.b*t.x+r.d*t.y+r.f}}function o(r,t){return t.map(function(t){return e(r,t)})}function a(r){return{a:parseFloat(r.a),b:parseFloat(r.b),c:parseFloat(r.c),d:parseFloat(r.d),e:parseFloat(r.e),f:parseFloat(r.f)}}n.r(t);var u=/^matrix\(\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*\)$/i;function i(r){var t=r.match(u);if(null===t||t.length<7)throw new Error("'"+r+"' is not a matrix");return{a:parseFloat(t[1]),b:parseFloat(t[2]),c:parseFloat(t[3]),d:parseFloat(t[4]),e:parseFloat(t[5]),f:parseFloat(t[6])}}function f(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function c(r){var t=r.a,n=r.b,e=r.c,o=r.d,a=r.e,u=r.f,i=t*o-n*e;return{a:o/i,b:n/-i,c:e/-i,d:t/i,e:(o*a-e*u)/-i,f:(n*a-t*u)/i}}var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r};function d(r){var t=function(r){return"number"==typeof r&&!isNaN(r)&&isFinite(r)};return"object"===(void 0===r?"undefined":s(r))&&r.hasOwnProperty("a")&&t(r.a)&&r.hasOwnProperty("b")&&t(r.b)&&r.hasOwnProperty("c")&&t(r.c)&&r.hasOwnProperty("d")&&t(r.d)&&r.hasOwnProperty("e")&&t(r.e)&&r.hasOwnProperty("f")&&t(r.f)}function p(r){return void 0===r}function l(r){return{a:1,c:0,e:r,b:0,d:1,f:arguments.length>1&&void 0!==arguments[1]?arguments[1]:0}}function y(){for(var r=arguments.length,t=Array(r),n=0;n<r;n++)t[n]=arguments[n];var e,o=function(r,t){return{a:r.a*t.a+r.c*t.b,c:r.a*t.c+r.c*t.d,e:r.a*t.e+r.c*t.f+r.e,b:r.b*t.a+r.d*t.b,d:r.b*t.c+r.d*t.d,f:r.b*t.e+r.d*t.f+r.f}};switch((t=Array.isArray(t[0])?t[0]:t).length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return o(t[0],t[1]);default:var a=(e=t,Array.isArray(e)?e:Array.from(e)),u=a[0],i=a[1],f=a.slice(2),c=o(u,i);return y.apply(void 0,[c].concat(function(r){if(Array.isArray(r)){for(var t=0,n=Array(r.length);t<r.length;t++)n[t]=r[t];return n}return Array.from(r)}(f)))}}var b=Math.cos,v=Math.sin,m=Math.PI;function h(r,t,n){var e=b(r),o=v(r),a={a:e,c:-o,e:0,b:o,d:e,f:0};return p(t)||p(n)?a:y([l(t,n),a,l(-t,-n)])}function x(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return h(r*m/180,t,n)}function w(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return p(t)&&(t=r),{a:r,c:0,e:0,b:0,d:t,f:0}}function g(r,t){return{a:1,c:r,e:0,b:t,d:1,f:0}}function F(r){return A(r)}function P(r){return A(r)}function A(r){return"matrix("+r.a+","+r.b+","+r.c+","+r.d+","+r.e+","+r.f+")"}n.d(t,"applyToPoint",function(){return e}),n.d(t,"applyToPoints",function(){return o}),n.d(t,"fromObject",function(){return a}),n.d(t,"fromString",function(){return i}),n.d(t,"identity",function(){return f}),n.d(t,"inverse",function(){return c}),n.d(t,"isAffineMatrix",function(){return d}),n.d(t,"rotate",function(){return h}),n.d(t,"rotateDEG",function(){return x}),n.d(t,"scale",function(){return w}),n.d(t,"shear",function(){return g}),n.d(t,"toCSS",function(){return F}),n.d(t,"toSVG",function(){return P}),n.d(t,"toString",function(){return A}),n.d(t,"transform",function(){return y}),n.d(t,"translate",function(){return l})}])});
//# sourceMappingURL=transformation-matrix.min.js.map
{
"name": "transformation-matrix",
"version": "1.7.0",
"version": "1.8.0",
"description": "2d transformation matrix functions written in ES6 syntax. Tree shaking ready!",

@@ -27,5 +27,6 @@ "main": "./build-commonjs/index.js",

"build-umd": "cross-env BABEL_ENV=es webpack --config ./webpack-umd.config.js",
"build-parser": "pegjs -o src/fromTransformAttribute.autogenerated.js --format es src/fromTransformAttribute.pegjs",
"clean": "del build-*",
"version": "npm-run-all clean test coverage coveralls build add-build-to-vcs",
"build": "npm-run-all clean build-commonjs build-es build-docs build-umd build-umd-min",
"build": "npm-run-all clean build-commonjs build-es build-docs build-umd build-umd-min build-parser",
"add-build-to-vcs": "git add -A README.md"

@@ -54,3 +55,3 @@ },

"babel-cli": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-loader": "^7.1.4",
"babel-plugin-transform-object-rest-spread": "^6.26.0",

@@ -65,7 +66,9 @@ "babel-preset-env": "^1.6.1",

"jsdoc-to-markdown": "^4.0.1",
"mocha": "^5.0.0",
"mocha": "^5.0.2",
"npm-run-all": "^4.1.2",
"nyc": "^11.4.1",
"webpack": "^3.10.0"
"pegjs": "^0.11.0-dev.225",
"webpack": "^4.1.0",
"webpack-cli": "^2.0.10"
}
}

@@ -58,2 +58,6 @@ <!-- THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -->

</dd>
<dt><a href="#fromTransformAttribute">fromTransformAttribute(transformString, generateMatrices)</a> ⇒ <code>Object</code></dt>
<dd><p>Parse SVG Trasform Attribute <a href="http://www.w3.org/TR/SVG/coords.html#TransformAttribute">http://www.w3.org/TR/SVG/coords.html#TransformAttribute</a> <br/>
Warning: This should be considered BETA until it is released a stable version of pegjs.</p>
</dd>
<dt><a href="#identity">identity()</a> ⇒ <code>Object</code></dt>

@@ -106,2 +110,4 @@ <dd><p>Identity matrix</p>

- **1.6** - Adds optional parameter support on `translate(tx)`, `scale(sx)`, `rotate(angle, cx, cy)`
- **1.7** - Upgrade deps
- **1.8** - Fixes [#12](https://github.com/chrvadala/transformation-matrix/issues/12), Adds `fromTransformAttribute`, Discontinues node 4 support

@@ -117,2 +123,3 @@ ## Some projects using transformation-matrix

- [forabi](https://github.com/forabi) (TypeScript definitions)
- [nidu](https://github.com/nidu) (PEG.js descriptor)

@@ -171,2 +178,16 @@ # API

<a name="fromTransformAttribute"></a>
## fromTransformAttribute(transformString, generateMatrices) ⇒ <code>Object</code>
Parse SVG Trasform Attribute http://www.w3.org/TR/SVG/coords.html#TransformAttribute <br/>
Warning: This should be considered BETA until it is released a stable version of pegjs.
**Kind**: global function
**Returns**: <code>Object</code> - Parsed matrices
| Param | Description |
| --- | --- |
| transformString | string |
| generateMatrices | boolean |
<a name="identity"></a>

@@ -173,0 +194,0 @@

@@ -5,3 +5,3 @@ /**

*/
const matrixRegex = /^matrix\(\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*,\s*(-?[0-9]*\.?[0-9]+)\s*\)$/i;
const matrixRegex = /^matrix\(\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*,\s*([0-9_\+\-\.e]+)\s*\)$/i;

@@ -15,3 +15,3 @@ /**

let parsed = string.match(matrixRegex);
if (parsed === null || parsed.length < 7)throw new Error(`'${string}' is not a matrix`);
if (parsed === null || parsed.length < 7) throw new Error(`'${string}' is not a matrix`);
return {

@@ -18,0 +18,0 @@ a: parseFloat(parsed[1]),

@@ -32,3 +32,7 @@ import {fromString,} from '../src/fromString';

assert.deepEqual(
fromString('matrix(+43e+21, -43e+21, +43e-21, -43e-21, 43e0, 0e0)'),
{a: +43e+21, b: -43e+21, c: +43e-21, d: -43e-21, e: 43, f: 0}, 'exponential format');
assert.throws(fromString.bind(this, 'matrix()'), /is not a matrix$/);

@@ -35,0 +39,0 @@ assert.throws(fromString.bind(this, 'matrix(1,2,3,4,5)'), /is not a matrix$/);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc