Name | Type | Description |
---|---|---|
renderer |
PIXI.Renderer |
A reference to the current renderer |
Example
import { Application, Graphics } from 'pixi.js';
// Create a new application (extract will be auto-added to renderer)
const app = new Application();
// Draw a red circle
const graphics = new Graphics()
.beginFill(0xFF0000)
.drawCircle(0, 0, 50);
// Render the graphics as an HTMLImageElement
const image = await app.renderer.extract.image(graphics);
document.body.appendChild(image);
Implements
- PIXI.ISystem
- IExtract
Methods
Will return a base64 encoded string of this target. It works by calling
Extract.canvas
and then running toDataURL on that.
Name | Type | Attributes | Description |
---|---|---|---|
target |
PIXI.DisplayObject | PIXI.RenderTexture |
<optional> |
A displayObject or renderTexture to convert. If left empty will use the main renderer |
format |
string |
<optional> |
Image format, e.g. "image/jpeg" or "image/webp". |
quality |
number |
<optional> |
JPEG or Webp compression from 0 to 1. Default is 0.92. |
frame |
PIXI.Rectangle |
<optional> |
The frame the extraction is restricted to. |
Returns:
Type | Description |
---|---|
Promise<string> |
|
canvas (target, frame) PIXI.ICanvas
Creates a Canvas element, renders this target to it and then returns it.
Name | Type | Attributes | Description |
---|---|---|---|
target |
PIXI.DisplayObject | PIXI.RenderTexture |
<optional> |
A displayObject or renderTexture to convert. If left empty will use the main renderer |
frame |
PIXI.Rectangle |
<optional> |
The frame the extraction is restricted to. |
Returns:
Type | Description |
---|---|
PIXI.ICanvas |
|
Destroys the extract.
Will return a HTML Image of the target
Name | Type | Attributes | Description |
---|---|---|---|
target |
PIXI.DisplayObject | PIXI.RenderTexture |
<optional> |
A displayObject or renderTexture to convert. If left empty will use the main renderer |
format |
string |
<optional> |
Image format, e.g. "image/jpeg" or "image/webp". |
quality |
number |
<optional> |
JPEG or Webp compression from 0 to 1. Default is 0.92. |
frame |
PIXI.Rectangle |
<optional> |
The frame the extraction is restricted to. |
Returns:
Type | Description |
---|---|
Promise<HTMLImageElement> |
|
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).
Name | Type | Attributes | Description |
---|---|---|---|
target |
PIXI.DisplayObject | PIXI.RenderTexture |
<optional> |
A displayObject or renderTexture to convert. If left empty will use the main renderer |
frame |
PIXI.Rectangle |
<optional> |
The frame the extraction is restricted to. |
Returns:
Type | Description |
---|---|
Uint8Array |
|