Newer
Older
pixi.js / packages / core / src / textures / resources / CanvasResource.js
@Michael Deal Michael Deal on 7 Jun 2019 700 bytes Change reference from `global` to `window`
import BaseImageResource from './BaseImageResource';

/**
 * Resource type for HTMLCanvasElement.
 * @class
 * @extends PIXI.resources.BaseImageResource
 * @memberof PIXI.resources
 * @param {HTMLCanvasElement} source - Canvas element to use
 */
export default class CanvasResource extends BaseImageResource
{
    /**
     * Used to auto-detect the type of resource.
     *
     * @static
     * @param {HTMLCanvasElement|OffscreenCanvas} source - The source object
     * @return {boolean} `true` if <canvas>
     */
    static test(source)
    {
        return (source && (
            source instanceof HTMLCanvasElement
            || source instanceof window.OffscreenCanvas
        ));
    }
}