pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
32 lines (28 loc) • 988 B
JavaScript
;
var Matrix = require('../../../maths/matrix/Matrix.js');
var applyMatrix = require('./applyMatrix.js');
;
function setUvs(tilingSprite, uvs) {
const texture = tilingSprite.texture;
const width = texture.frame.width;
const height = texture.frame.height;
let anchorX = 0;
let anchorY = 0;
if (tilingSprite.applyAnchorToTexture) {
anchorX = tilingSprite.anchor.x;
anchorY = tilingSprite.anchor.y;
}
uvs[0] = uvs[6] = -anchorX;
uvs[2] = uvs[4] = 1 - anchorX;
uvs[1] = uvs[3] = -anchorY;
uvs[5] = uvs[7] = 1 - anchorY;
const textureMatrix = Matrix.Matrix.shared;
textureMatrix.copyFrom(tilingSprite._tileTransform.matrix);
textureMatrix.tx /= tilingSprite.width;
textureMatrix.ty /= tilingSprite.height;
textureMatrix.invert();
textureMatrix.scale(tilingSprite.width / width, tilingSprite.height / height);
applyMatrix.applyMatrix(uvs, 2, 0, textureMatrix);
}
exports.setUvs = setUvs;
//# sourceMappingURL=setUvs.js.map