JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q31695F
  • License MIT

matrix2d

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

Docs

扩展 API:

  • transformPoints(points: Point[], origin: Point): Points[]

  • transformPointWithOrigin(x: number,y: number, point: {x: number, y: number}) 变换矩阵应用于坐标时支持自定义基点point,示例:

作用同 transformPoint(x, y, 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)
  • flipX() flipY() flipOrigin()

  • rotate(deg, cx,cy)

  • scale(x,y, cx,cy)

  • scaleX(x) scaleY(y)

  • skewX(x) skewY(y)

  • translateX(x) translateY(y)

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);