nitro-renderer/packages/room/src/ImageResult.ts

20 lines
495 B
TypeScript
Raw Normal View History

2024-03-20 02:53:17 +01:00
import { IImageResult } from '@nitrots/api';
import { TextureUtils } from '@nitrots/utils';
import { Texture } from 'pixi.js';
2021-03-17 03:02:09 +01:00
2022-11-02 09:25:40 +01:00
export class ImageResult implements IImageResult
2021-03-17 03:02:09 +01:00
{
2022-03-03 01:21:30 +01:00
public id: number = 0;
2024-03-20 02:53:17 +01:00
public data: Texture = null;
2022-03-03 01:21:30 +01:00
public image: HTMLImageElement = null;
2021-03-17 03:02:09 +01:00
2023-07-12 03:55:42 +02:00
public async getImage(): Promise<HTMLImageElement>
2021-03-17 03:02:09 +01:00
{
2022-11-02 23:44:30 +01:00
if(this.image) return this.image;
2021-03-17 03:02:09 +01:00
2022-11-02 23:44:30 +01:00
if(!this.data) return null;
2021-03-17 03:02:09 +01:00
2023-07-12 03:55:42 +02:00
return await TextureUtils.generateImage(this.data);
2021-03-17 03:02:09 +01:00
}
2021-08-03 05:50:15 +02:00
}