Package Exports
- matrix2d.js
- matrix2d.js/dist/cjs/main.js
- matrix2d.js/dist/esm/main.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (matrix2d.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
matrix2d.js
Matrix2D from CreateJS
扩展 API:
transformPointWithOrigin(x: number,y: number, point: {x: number, y: number})
变换矩阵应用于坐标时支持自定义基点point
,示例:
const mtx = new Matrix2D();
mtx.rotate(45);
const rect = {
x: 100,
y: 100,
width: 100,
height: 100,
};
const p = mtx.transformPointWithOrigin(rect.x, rect.y, {
x: rect.x + rect.width / 2,
y: rect.y + = rect.height / 2,
});
// 旋转45角度后的新坐标
console.log(p)
Usage
npm install --save matrix2d.js
import Matrix2D from "matrix2d.js";
const mtx = new Matrix2D();
mtx.appendTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation);