How to use the @pixi/canvas-renderer.CanvasRenderer function in @pixi/canvas-renderer

To help you get started, we’ve selected a few @pixi/canvas-renderer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pixijs / pixi.js / packages / canvas / canvas-graphics / src / Graphics.js View on Github external
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,
    });

@pixi/canvas-renderer

Rendering using the Canvas API

MIT
Latest version published 8 months ago

Package Health Score

88 / 100
Full package analysis

Similar packages