Name | Type | Description |
---|---|---|
renderer |
Renderer |
The renderer this System works for. |
Example
import { Application, Graphics } from 'pixi.js';
// Create a new application (extract will be auto-added to renderer)
const app = new Application();
await app.init();
// Draw a red circle
const graphics = new Graphics()
.circle(0, 0, 50);
.fill(0xFF0000)
// Render the graphics as an HTMLImageElement
const image = await app.renderer.extract.image(graphics);
document.body.appendChild(image);
Implements
Members
defaultImageOptions ImageOptions static
Default options for creating an image.
Properties:
Name | Type | Default | Description |
---|---|---|---|
format |
The format of the image. |
||
quality |
number |
1
|
The quality of the image. |
Methods
Will return a base64 encoded string of this target. It works by calling
Extract.canvas
and then running toDataURL on that.
Name | Type | Description |
---|---|---|
options |
ExtractImageOptions | Container | Texture |
The options for creating the image, or the target to extract |
Returns:
Type | Description |
---|---|
Promise<string> |
Creates a Canvas element, renders this target to it and then returns it.
Name | Type | Description |
---|---|---|
options |
ExtractOptions | Container | Texture |
The options for creating the canvas, or the target to extract |
Returns:
Type | Description |
---|---|
ICanvas |
|
Will extract a HTMLImage of the target and download it
Name | Type | Description |
---|---|---|
options |
ExtractDownloadOptions | Container | Texture |
The options for downloading and extracting the image, or the target to extract |
Will return a HTML Image of the target
Name | Type | Description |
---|---|---|
options |
ExtractImageOptions | Container | Texture |
The options for creating the image, or the target to extract |
Returns:
Type | Description |
---|---|
Promise<HTMLImageElement> |
|
Logs the target to the console as an image. This is a useful way to debug what's happening in the renderer.
Name | Type | Description |
---|---|---|
options |
(ExtractOptions & { width? : number }) | Container | Texture |
The options for logging the image, or the target to log |
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 | Description |
---|---|---|
options |
ExtractOptions | Container | Texture |
The options for extracting the image, or the target to extract |
Returns:
Type | Description |
---|---|
GetPixelsOutput |
|
Will return a texture of the target
Name | Type | Description |
---|---|---|
options |
ExtractOptions | Container | Texture |
The options for creating the texture, or the target to extract |
Returns:
Type | Description |
---|---|
Texture |
|