refactor: image src
This commit is contained in:
parent
18dd5eb75c
commit
fcb7456109
|
@ -20,6 +20,7 @@ export default class Image extends Resource {
|
|||
isFake: true,
|
||||
width: 0,
|
||||
};
|
||||
this.uri = '';
|
||||
}
|
||||
|
||||
// @todo Implement refcount with PIXI cache and we can do this.
|
||||
|
@ -40,6 +41,7 @@ export default class Image extends Resource {
|
|||
}
|
||||
|
||||
async load(buffer, uri) {
|
||||
this.uri = uri;
|
||||
if (buffer) {
|
||||
if ('web' !== process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
const {height, width} = imageSize(Buffer.from(buffer));
|
||||
|
@ -111,6 +113,10 @@ export default class Image extends Resource {
|
|||
return [this.width, this.height];
|
||||
}
|
||||
|
||||
get src() {
|
||||
return this.texture?.baseTexture.resource.source.src || this.uri;
|
||||
}
|
||||
|
||||
subimage(rectangle) {
|
||||
const subimage = new Image();
|
||||
if (this.texture.isFake) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user