Options
All
  • Public
  • Public/Protected
  • All
Menu

This class provides renderer-specific plugins for exporting content from a renderer. For instance, these plugins can be used for saving an Image, Canvas element or for exporting the raw image data (pixels).

Do not instantiate these plugins directly. It is available from the renderer.plugins property. See {@link PIXI.CanvasRenderer#plugins} or {@link PIXI.Renderer#plugins}.

example

// Create a new app (will auto-add extract plugin to renderer) const app = new PIXI.Application();

// Draw a red circle const graphics = new PIXI.Graphics() .beginFill(0xFF0000) .drawCircle(0, 0, 50);

// Render the graphics as an HTMLImageElement const image = app.renderer.plugins.extract.image(graphics); document.body.appendChild(image);

memberof

PIXI

Hierarchy

  • Extract

Implements

Index

Constructors

constructor

  • Parameters

    • renderer: Renderer

      A reference to the current renderer

    Returns Extract

Properties

Private renderer

renderer: any

Methods

base64

  • Will return a a base64 encoded string of this target. It works by calling Extract.getCanvas and then running toDataURL on that.

    Parameters

    • target: DisplayObject | RenderTexture

      A displayObject or renderTexture to convert. If left empty will use the main renderer

    • Optional format: string
    • Optional quality: number

    Returns string

    A base64 encoded string of the texture.

canvas

  • Creates a Canvas element, renders this target to it and then returns it.

    Parameters

    Returns HTMLCanvasElement

    A Canvas element with the texture rendered on.

destroy

  • destroy(): void
  • Destroys the extract

    Returns void

image

  • Will return a HTML Image of the target

    Parameters

    • target: DisplayObject | RenderTexture

      A displayObject or renderTexture to convert. If left empty will use the main renderer

    • Optional format: string
    • Optional quality: number

    Returns HTMLImageElement

    HTML Image of the target

pixels

  • Will return a one-dimensional array containing the pixel data of the entire texture in RGBA order, with integer values between 0 and 255 (included).

    Parameters

    Returns Uint8Array

    One-dimensional array containing the pixel data of the entire texture

Static Private arrayPostDivide

  • arrayPostDivide(pixels: Uint8Array | number[] | Uint8ClampedArray, out: Uint8Array | number[] | Uint8ClampedArray): void
  • Takes premultiplied pixel data and produces regular pixel data

    Parameters

    • pixels: Uint8Array | number[] | Uint8ClampedArray

      array of pixel data

    • out: Uint8Array | number[] | Uint8ClampedArray

      output array

    Returns void

Generated using TypeDoc