feat: Image::subimage

This commit is contained in:
cha0s 2019-03-25 18:53:34 -05:00
parent 5377617dfc
commit b29911fbd1

View File

@ -47,6 +47,18 @@ export class Image extends Resource {
return [this.width, this.height];
}
subimage(rectangle) {
const frame = {
x: rectangle[0],
y: rectangle[1],
width: rectangle[2],
height: rectangle[3],
};
const subimage = new Image();
subimage.texture = new PIXI.Texture(this.texture, frame);
return subimage;
}
get width() {
if (!this.texture) {
return 0;