UNPKG

pixi.js

Version:

<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">

31 lines (28 loc) 845 B
import { CanvasSource } from '../sources/CanvasSource.mjs'; import { Texture } from '../Texture.mjs'; "use strict"; const canvasCache = /* @__PURE__ */ new Map(); function getCanvasTexture(canvas, options) { if (!canvasCache.has(canvas)) { const texture = new Texture({ source: new CanvasSource({ resource: canvas, ...options }) }); const onDestroy = () => { if (canvasCache.get(canvas) === texture) { canvasCache.delete(canvas); } }; texture.once("destroy", onDestroy); texture.source.once("destroy", onDestroy); canvasCache.set(canvas, texture); } return canvasCache.get(canvas); } function hasCachedCanvasTexture(canvas) { return canvasCache.has(canvas); } export { getCanvasTexture, hasCachedCanvasTexture }; //# sourceMappingURL=getCanvasTexture.mjs.map