Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
calculateSpriteMatrix(outputMatrix, sprite)
{
const { sourceFrame, destinationFrame } = this.activeState;
const { orig } = sprite._texture;
const mappedMatrix = outputMatrix.set(destinationFrame.width, 0, 0,
destinationFrame.height, sourceFrame.x, sourceFrame.y);
const worldTransform = sprite.worldTransform.copyTo(Matrix.TEMP_MATRIX);
worldTransform.invert();
mappedMatrix.prepend(worldTransform);
mappedMatrix.scale(1.0 / orig.width, 1.0 / orig.height);
mappedMatrix.translate(sprite.anchor.x, sprite.anchor.y);
return mappedMatrix;
}
calculateSpriteMatrix(outputMatrix, sprite)
{
const { sourceFrame, destinationFrame } = this.activeState;
const { orig } = sprite._texture;
const mappedMatrix = outputMatrix.set(destinationFrame.width, 0, 0,
destinationFrame.height, sourceFrame.x, sourceFrame.y);
const worldTransform = sprite.worldTransform.copyTo(Matrix.TEMP_MATRIX);
worldTransform.invert();
mappedMatrix.prepend(worldTransform);
mappedMatrix.scale(1.0 / orig.width, 1.0 / orig.height);
mappedMatrix.translate(sprite.anchor.x, sprite.anchor.y);
return mappedMatrix;
}
export function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite)
{
const orig = sprite._texture.orig;
const mappedMatrix = outputMatrix.set(textureSize.width, 0, 0, textureSize.height, filterArea.x, filterArea.y);
const worldTransform = sprite.worldTransform.copyTo(Matrix.TEMP_MATRIX);
worldTransform.invert();
mappedMatrix.prepend(worldTransform);
mappedMatrix.scale(1.0 / orig.width, 1.0 / orig.height);
mappedMatrix.translate(sprite.anchor.x, sprite.anchor.y);
return mappedMatrix;
}