UNPKG

754 BJavaScriptView Raw
1import { BaseImageResource } from "./BaseImageResource.mjs";
2class CanvasResource extends BaseImageResource {
3 /**
4 * @param source - Canvas element to use
5 */
6 // eslint-disable-next-line @typescript-eslint/no-useless-constructor
7 constructor(source) {
8 super(source);
9 }
10 /**
11 * Used to auto-detect the type of resource.
12 * @param {*} source - The source object
13 * @returns {boolean} `true` if source is HTMLCanvasElement or OffscreenCanvas
14 */
15 static test(source) {
16 const { OffscreenCanvas } = globalThis;
17 return OffscreenCanvas && source instanceof OffscreenCanvas ? !0 : globalThis.HTMLCanvasElement && source instanceof HTMLCanvasElement;
18 }
19}
20export {
21 CanvasResource
22};
23//# sourceMappingURL=CanvasResource.mjs.map