Based on DOM Geometry Interfaces Module Level 1
Only provide polyfill for platform without DOMMatrix
, DOMPoint
, DOMRect
.
But use the browser native implementation if possible.
Still In development
https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrix
let mat: DOMMatrix = createMatrix()
mat.translateSelf(x, y, z)
mat.rotateSelf(x, y, z)
and add few helpers:
mapMatrix(matrix: DOMMatrix, (i: number, j: number, val: number) => number)
resetMatrix(matrix: DOMMatrix)
-> set it to identity valuesmatrix3dValues(matrix: DOMMatrix)
-> convert matrix3d to number[]matrix3dToCSS(matrix: DOMMatrix)
-> convert to css Matrix 3dmatrix2dToCSS(matrix: DOMMatrix)
-> convert to css Matrix 2dhttps://developer.mozilla.org/en-US/docs/Web/API/DOMPoint
let point: DOMPoint = createPoint(x, y)
point.matrixTransform(mat)
https://developer.mozilla.org/en-US/docs/Web/API/DOMRect
let rect: DOMRect = createRect(x, y, width, height)
rect.top
rect.left
rect.right
rect.bottom