Files
nothoughts/node_modules/pixi.js/lib/scene/text-html/utils/getTemporaryCanvasFromImage.mjs.map
2025-08-04 18:57:35 +02:00

1 line
2.0 KiB
Plaintext

{"version":3,"file":"getTemporaryCanvasFromImage.mjs","sources":["../../../../src/scene/text-html/utils/getTemporaryCanvasFromImage.ts"],"sourcesContent":["import { CanvasPool } from '../../../rendering/renderers/shared/texture/CanvasPool';\n\n/**\n * This function converts an image to a canvas, and returns the canvas.\n * It is used to convert images to canvases to work around a CORS issue where WebGPU cannot\n * upload an SVGImage to a texture.\n *\n * It uses the CanvasPool to get an optimal canvas and context, and then draws the image onto it.\n * This canvas is immediately returned to the CanvasPool for reuse, so use the result straight away!\n * (eg upload it to the GPU!)\n * @param image - The image to convert to a canvas.\n * @param resolution - The resolution of the canvas.\n */\nexport function getTemporaryCanvasFromImage(image: HTMLImageElement, resolution: number): HTMLCanvasElement\n{\n // Get an optimal canvas and context from the CanvasPool, based on the\n // dimensions of the image and the desired resolution.\n const canvasAndContext = CanvasPool.getOptimalCanvasAndContext(\n image.width,\n image.height,\n resolution\n );\n\n // Clear the context of the canvas, and draw the image onto it.\n const { context } = canvasAndContext;\n\n context.clearRect(0, 0, image.width, image.height);\n context.drawImage(image, 0, 0);\n\n // Return the canvas and context to the CanvasPool.\n CanvasPool.returnCanvasAndContext(canvasAndContext);\n\n // Return the canvas.\n return canvasAndContext.canvas as HTMLCanvasElement;\n}\n\n"],"names":[],"mappings":";;;AAagB,SAAA,2BAAA,CAA4B,OAAyB,UACrE,EAAA;AAGI,EAAA,MAAM,mBAAmB,UAAW,CAAA,0BAAA;AAAA,IAChC,KAAM,CAAA,KAAA;AAAA,IACN,KAAM,CAAA,MAAA;AAAA,IACN,UAAA;AAAA,GACJ,CAAA;AAGA,EAAM,MAAA,EAAE,SAAY,GAAA,gBAAA,CAAA;AAEpB,EAAA,OAAA,CAAQ,UAAU,CAAG,EAAA,CAAA,EAAG,KAAM,CAAA,KAAA,EAAO,MAAM,MAAM,CAAA,CAAA;AACjD,EAAQ,OAAA,CAAA,SAAA,CAAU,KAAO,EAAA,CAAA,EAAG,CAAC,CAAA,CAAA;AAG7B,EAAA,UAAA,CAAW,uBAAuB,gBAAgB,CAAA,CAAA;AAGlD,EAAA,OAAO,gBAAiB,CAAA,MAAA,CAAA;AAC5B;;;;"}