Example
import { utils } from 'pixi.js';
// Extend PIXI's internal Event Emitter.
class MyEmitter extends utils.EventEmitter {
constructor() {
super();
console.log('Emitter created!');
}
}
// Get info on current device
console.log(utils.isMobile);
Classes
Interface Definitions
-
Properties:
Name Type Description charset
string data
string The actual data
encoding
string Data encoding, eg.
base64
mediaType
string type, eg.
image
subType
string Sub type, eg.
png
Members
- TODO
-
- Describe property usage
- TODO
-
- Describe property usage
- TODO
-
- Describe property usage
A simple JS library that detects mobile devices.
- See:
Properties:
Name | Type | Description |
---|---|---|
amazon |
object | |
amazon |
boolean |
.device - |
amazon |
boolean |
.tablet - |
amazon |
boolean |
.phone - |
android |
object | |
android |
boolean |
.device - |
android |
boolean |
.tablet - |
android |
boolean |
.phone - |
any |
boolean |
|
apple |
object | |
apple |
boolean |
.device - |
apple |
boolean |
.tablet - |
apple |
boolean |
.phone - |
apple |
boolean |
.ipod - |
phone |
boolean |
|
tablet |
boolean |
|
windows |
object | |
windows |
boolean |
.device - |
windows |
boolean |
.tablet - |
windows |
boolean |
.phone - |
Browser and Node.js compatible path utilities. All paths that are passed in will become normalized to have posix separators.
maps premultiply flag and blendMode to adjusted blendMode
Node.js compatible URL utilities.
Methods
A polygon triangulation library
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
vertices |
Array<number> |
A flat array of vertex coordinates |
||
holes |
Array<number> |
<optional> |
An array of hole indices |
|
dimensions |
number |
<optional> |
2 |
The number of coordinates per vertex in the input array |
Returns:
Type | Description |
---|---|
Array<number> | Triangulated polygon |
Removes all textures from cache, but does not destroy them
changes blendMode according to texture format
Name | Type | Description |
---|---|---|
blendMode |
number |
supposed blend mode |
premultiplied |
boolean |
whether source is premultiplied |
Returns:
Type | Description |
---|---|
number | true blend mode for this texture |
Generic Mask Stack data structure
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
size |
number |
Number of quads |
||
outBuffer |
Uint16Array | Uint32Array |
<optional> |
undefined |
Buffer for output, length has to be |
Returns:
Type | Description |
---|---|
Uint16Array | Uint32Array |
|
decomposeDataUri (dataUri) PIXI.utils.DecomposedDataUri | unknown
Split a data URI into components. Returns undefined if
parameter dataUri
is not a valid data URI.
Name | Type | Description |
---|---|---|
dataUri |
string |
the data URI to check |
Returns:
Type | Description |
---|---|
PIXI.utils.DecomposedDataUri | unknown | The decomposed data uri or undefined |
Helper for warning developers about deprecated features & settings. A stack track for warnings is given; useful for tracking-down where deprecated methods/properties/classes are being used within the code.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
version |
string |
The version where the feature became deprecated |
||
message |
string |
Message should include what is deprecated, where, and the new solution |
||
ignoreDepth |
number |
<optional> |
3 |
The number of steps to ignore at the top of the error stack this is mostly to ignore internal deprecation calls. |
Destroys all texture in the cache
detectVideoAlphaMode () Promise<PIXI.ALPHA_MODES>
Helper for detecting the correct alpha mode for video textures.
For some reason, some browsers/devices/WebGL implementations premultiply the alpha
of a video before and then a second time if UNPACK_PREMULTIPLY_ALPHA_WEBGL
is true. So the video is premultiplied twice if the alpha mode is UNPACK
.
In this case we need the alpha mode to be PMA
. This function detects
the upload behavior by uploading a white 2x2 webm with 50% alpha
without UNPACK_PREMULTIPLY_ALPHA_WEBGL
and then checking whether
the uploaded pixels are premultiplied.
Returns:
Type | Description |
---|---|
Promise<PIXI.ALPHA_MODES> | The correct alpha mode for video textures. |
getCanvasBoundingBox (canvas) PIXI.utils.BoundingBox
Measuring the bounds of a canvas' visible (non-transparent) pixels.
Name | Type | Description |
---|---|---|
canvas |
PIXI.ICanvas |
The canvas to measure. |
- Since:
- 7.1.0
Returns:
Type | Description |
---|---|
PIXI.utils.BoundingBox | The bounding box of the canvas' visible pixels. |
get the resolution / device pixel ratio of an asset by looking for the prefix used by spritesheets and image urls
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
url |
string |
the image path |
||
defaultValue |
number |
<optional> |
1 |
the defaultValue if no filename prefix is set. |
Returns:
Type | Description |
---|---|
number | resolution / device pixel ratio of an asset |
Converts a hexadecimal color number to an [R, G, B] array of normalized floats (numbers from 0.0 to 1.0).
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
hex |
number |
The hexadecimal number to convert |
||
out |
Array<number> |
<optional> |
[] |
If supplied, this array will be used rather than returning a new one |
Returns:
Type | Description |
---|---|
Array<number> | An array representing the [R, G, B] of the color where all values are floats. |
Converts a hexadecimal color number to a string.
Name | Type | Description |
---|---|---|
hex |
number |
Number in hex (e.g., |
- See:
Returns:
Type | Description |
---|---|
string | The string color (e.g., "#ffffff" ). |
Checks if a number is a power of two.
Name | Type | Description |
---|---|---|
v |
number |
input value |
Returns:
Type | Description |
---|---|
boolean | true if value is power of two |
Helper for checking for WebGL support.
Returns:
Type | Description |
---|---|
boolean | Is WebGL supported. |
Computes ceil of log base 2
Name | Type | Description |
---|---|---|
v |
number |
input value |
Returns:
Type | Description |
---|---|
number | logarithm base 2 |
Rounds to next power of two.
Name | Type | Description |
---|---|---|
v |
number |
input value |
Returns:
Type | Description |
---|---|
number |
|
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rgb |
Float32Array | number<Array> | |||
alpha |
number | |||
out |
Float32Array |
<optional> |
||
premultiply |
boolean |
<optional> |
true |
Returns:
Type | Description |
---|---|
Float32Array |
Name | Type | Description |
---|---|---|
tint |
number | |
alpha |
number |
Returns:
Type | Description |
---|---|
number |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
tint |
number | |||
alpha |
number | |||
out |
Float32Array |
<optional> |
||
premultiply |
boolean |
<optional> |
true |
Returns:
Type | Description |
---|---|
Float32Array |
Remove items from a javascript array without generating garbage
Name | Type | Description |
---|---|---|
arr |
Array<any> |
Array to remove elements from |
startIdx |
number |
starting index |
removeCount |
number |
how many to remove |
Converts a color as an [R, G, B] array of normalized floats to a hexadecimal number.
Name | Type | Description |
---|---|---|
rgb |
Array<number> |
Array of numbers where all values are normalized floats from 0.0 to 1.0. |
- See:
Returns:
Type | Description |
---|---|
number | Number in hexadecimal. |
Returns sign of number
Name | Type | Description |
---|---|---|
n |
number |
the number to check the sign of |
Returns:
Type | Description |
---|---|
number | 0 if n is 0, -1 if n is negative, 1 if n is positive |
Converts a string to a hexadecimal color number.
Name | Type | Description |
---|---|---|
string |
string |
The string color (e.g., |
- See:
Returns:
Type | Description |
---|---|
number | Number in hexadecimal. |
Trim transparent borders from a canvas.
Name | Type | Description |
---|---|---|
canvas |
PIXI.ICanvas |
The canvas to trim. |
Returns:
Type | Description |
---|---|
{ width : number, height : number, data : ImageData | null } | The trimmed canvas data. |
Gets the next unique identifier
Returns:
Type | Description |
---|---|
number | The next unique identifier to use. |