Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Graphics.prototype.generateCanvasTexture = function generateCanvasTexture(scaleMode, resolution = 1)
{
const bounds = this.getLocalBounds();
const canvasBuffer = RenderTexture.create(bounds.width, bounds.height, scaleMode, resolution);
if (!canvasRenderer)
{
canvasRenderer = new CanvasRenderer();
}
this.transform.updateLocalTransform();
this.transform.localTransform.copyTo(tempMatrix);
tempMatrix.invert();
tempMatrix.tx -= bounds.x;
tempMatrix.ty -= bounds.y;
canvasRenderer.render(this, canvasBuffer, true, tempMatrix);
const texture = Texture.from(canvasBuffer.baseTexture._canvasRenderTarget.canvas, {
scaleMode,
});