Skip to content

Commit ee48675

Browse files
committed
Fixed trimmed TileSprites in Canvas (WebGL still broken, as it's broken in Pixi also)
1 parent 72530d9 commit ee48675

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

src/pixi/extras/TilingSprite.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,19 +391,36 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo)
391391
{
392392
if (isFrame)
393393
{
394-
targetWidth = frame.width;
395-
targetHeight = frame.height;
394+
if (texture.crop)
395+
{
396+
targetWidth = texture.crop.width;
397+
targetHeight = texture.crop.height;
398+
}
399+
else
400+
{
401+
targetWidth = frame.width;
402+
targetHeight = frame.height;
403+
}
396404

397405
newTextureRequired = true;
398406
}
399407
}
400408
else
401409
{
402-
targetWidth = PIXI.getNextPowerOfTwo(frame.width);
403-
targetHeight = PIXI.getNextPowerOfTwo(frame.height);
410+
if (texture.crop)
411+
{
412+
targetWidth = PIXI.getNextPowerOfTwo(texture.crop.width);
413+
targetHeight = PIXI.getNextPowerOfTwo(texture.crop.height);
414+
}
415+
else
416+
{
417+
targetWidth = PIXI.getNextPowerOfTwo(frame.width);
418+
targetHeight = PIXI.getNextPowerOfTwo(frame.height);
419+
}
420+
newTextureRequired = true;
404421

405422
// If the BaseTexture dimensions don't match the texture frame then we need a new texture anyway because it's part of a texture atlas
406-
if (frame.width !== targetWidth || frame.height !== targetHeight || texture.baseTexture.width !== targetWidth || texture.baseTexture.height || targetHeight) newTextureRequired = true;
423+
// if (frame.width !== targetWidth || frame.height !== targetHeight || texture.baseTexture.width !== targetWidth || texture.baseTexture.height || targetHeight) newTextureRequired = true;
407424
}
408425

409426
if (newTextureRequired)

0 commit comments

Comments
 (0)