feat: Image::subimage
This commit is contained in:
parent
5377617dfc
commit
b29911fbd1
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user