Generalized convenience utilities for PIXI.
Example
// Extend PIXI's internal Event Emitter.
class MyEmitter extends PIXI.utils.EventEmitter {
constructor() {
super();
console.log("Emitter created!");
}
}
// Get info on current device
console.log(PIXI.utils.isMobile);
// Convert hex color to string
console.log(PIXI.utils.hex2string(0xff00ff)); // returns: "#ff00ff"
Classes
Members
-
staticPIXI.utils._saidHelloboolean
-
- Deprecated
- since 4.1.0
- See:
Methods
-
staticPIXI.utils.canUseNewCanvasBlendModes(){boolean}
-
- Deprecated
- Yes
- See:
Returns:
Type Description boolean Can use blend modes. -
staticPIXI.utils.clearTextureCache()
-
Removes all textures from cache, but does not destroy them
-
staticPIXI.utils.decomposeDataUri(dataUri){DecomposedDataUri|undefined}
-
Split a data URI into components. Returns undefined if parameter
dataUriis not a valid data URI.Name Type Description dataUristring the data URI to check
Returns:
Type Description DecomposedDataUri | undefined The decomposed data uri or undefined -
staticPIXI.utils.destroyTextureCache()
-
Destroys all texture in the cache
-
staticPIXI.utils.getResolutionOfUrl(url, defaultValue){number}
-
get the resolution / device pixel ratio of an asset by looking for the prefix used by spritesheets and image urls
Name Type Default Description urlstring the image path
defaultValuenumber 1 optional the defaultValue if no filename prefix is set.
Returns:
Type Description number resolution / device pixel ratio of an asset -
staticPIXI.utils.getSvgSize(svgString){Size|undefined}
-
Get size from an svg string using regexp.
Name Type Description svgStringstring a serialized svg element
Returns:
Type Description Size | undefined image extension -
staticPIXI.utils.getUrlFileExtension(url){string|undefined}
-
Get type of the image by regexp for extension. Returns undefined for unknown extensions.
Name Type Description urlstring the image path
Returns:
Type Description string | undefined image extension -
staticPIXI.utils.hex2rgb(hex, out){Array.<number>}
-
Converts a hex color number to an [R, G, B] array
Name Type Default Description hexnumber The number to convert
outArray.<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. -
staticPIXI.utils.hex2string(hex){string}
-
Converts a hex color number to a string.
Name Type Description hexnumber Number in hex
Returns:
Type Description string The string color. -
staticPIXI.utils.isMobile(){Object}
-
Returns:
Type Description Object -
staticPIXI.utils.isWebGLSupported(){boolean}
-
Helper for checking for webgl support
Returns:
Type Description boolean is webgl supported -
staticPIXI.utils.pluginTarget(){mixin}
-
Returns:
Type Description mixin -
staticPIXI.utils.removeItems(arr, startIdx, removeCount)
-
Remove a range of items from an array
Name Type Description arrArray.<*> The target array
startIdxnumber The index to begin removing from (inclusive)
removeCountnumber How many items to remove
-
staticPIXI.utils.rgb2hex(rgb){number}
-
Converts a color as an [R, G, B] array to a hex number
Name Type Description rgbArray.<number> rgb array
Returns:
Type Description number The color number -
staticPIXI.utils.sayHello(type)
-
Logs out the version and renderer information for this running instance of PIXI. If you don't want to see this message you can run
PIXI.utils.skipHello()before creating your renderer. Keep in mind that doing that will forever makes you a jerk face.Name Type Description typestring The string renderer type to log.
-
staticPIXI.utils.sign(n){number}
-
Returns sign of number
Name Type Description nnumber the number to check the sign of
Returns:
Type Description number 0 if nis 0, -1 ifnis negative, 1 ifnis positive -
staticPIXI.utils.skipHello()
-
Skips the hello message of renderers that are created after this is run.
-
staticPIXI.utils.uid(){number}
-
Gets the next unique identifier
Returns:
Type Description number The next unique identifier to use. -
staticPIXI.utils.uuid(){number}
-
- Deprecated
- since version 3.0.6
- See:
Returns:
Type Description number The uid