Created
September 24, 2024 08:14
-
-
Save malko/b50165267283fcd435cd67903c42771c to your computer and use it in GitHub Desktop.
matrix transform apply
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @typedef {[number,number,number,number,number,number]} Matrix*/ | |
const transformApply = (/**@type {Matrix} */matrix, point=[0,0]) => { | |
// extract the transformation matrix values | |
const [scaleX, skewY, skewX, scaleY, translateX, translateY] = matrix | |
const [x, y] = point | |
// apply the transformation matrix to the point | |
return [ | |
x * scaleX + y * skewX + translateX, | |
x * skewY + y * scaleY + translateY | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment