| Name | Type | Default | Description |
|---|---|---|---|
source |
HTMLImageElement | HTMLCanvasElement |
optional
the source object of the texture. |
|
scaleMode |
number | PIXI.settings.SCALE_MODE |
optional
See PIXI.SCALE_MODES for possible values |
resolution |
number | 1 |
optional
The resolution / device pixel ratio of the texture |
Extends
- EventEmitter
Members
-
Set to true once the base texture has successfully loaded.
This is never true if the underlying source fails to load or has no texture data.
-
The height of the base texture set when the image has loaded
-
Type of image defined in source, eg.
pngorsvg -
The image url of the texture
-
Set to true if the source is currently loading.
If an Image source is loading the 'loaded' or 'error' event will be dispatched when the operation ends. An underyling source that is immediately-available bypasses loading entirely.
-
Set this to true if a mipmap of this texture needs to be generated. This value needs to be set before the texture is used Also the texture must be a power of two size to work
- See:
-
The image source that is used to create the texture. This is used to store the original Svg source when it is replaced with a canvas element.
TODO: Currently not in use but could be used when re-scaling svg.
-
Controls if RGB channels should be pre-multiplied by Alpha (WebGL only) All blend modes, and shaders written for default value. Change it on your own risk.
- Default Value:
- true
-
Used to store the actual height of the source of this texture
-
Used to store the actual width of the source of this texture
-
The resolution / device pixel ratio of the texture
- Default Value:
- 1
-
The scale mode to apply when scaling this texture
- Default Value:
- PIXI.settings.SCALE_MODE
- See:
-
The image source that is used to create the texture.
TODO: Make this a setter that calls loadSource();
-
Scale for source image. Used with Svg images to scale them before rasterization.
-
The ids under which this BaseTexture has been added to the base texture cache. This is automatically set as long as BaseTexture.addToCache is used, but may not be set if a BaseTexture is added directly to the BaseTextureCache array.
-
The width of the base texture set when the image has loaded
-
WebGL Texture wrap mode
- See:
Methods
-
Adds a BaseTexture to the global BaseTextureCache. This cache is shared across the whole PIXI object.
Name Type Description baseTexturePIXI.BaseTexture The BaseTexture to add to the cache.
idstring The id that the BaseTexture will be stored against.
-
PIXI.BaseTexture.from (source, scaleMode, sourceScale)PIXI.BaseTexture static
-
Helper function that creates a base texture based on the source you provide. The source can be - image url, image element, canvas element. If the source is an image url or an image element and not in the base texture cache, it will be created and loaded.
Name Type Default Description sourcestring | HTMLImageElement | HTMLCanvasElement The source to create base texture from.
scaleModenumber PIXI.settings.SCALE_MODE optional See PIXI.SCALE_MODES for possible values
sourceScalenumber (auto) optional Scale for the original image, used with Svg images.
Returns:
Type Description PIXI.BaseTexture The new base texture. -
PIXI.BaseTexture.fromCanvas (canvas, scaleMode, origin)PIXI.BaseTexture static
-
Helper function that creates a base texture from the given canvas element.
Name Type Default Description canvasHTMLCanvasElement The canvas element source of the texture
scaleModenumber See PIXI.SCALE_MODES for possible values
originstring 'canvas' optional A string origin of who created the base texture
Returns:
Type Description PIXI.BaseTexture The new base texture. -
PIXI.BaseTexture.fromImage (imageUrl, crossorigin, scaleMode, sourceScale)PIXI.BaseTexture static
-
Helper function that creates a base texture from the given image url. If the image is not in the base texture cache it will be created and loaded.
Name Type Default Description imageUrlstring The image url of the texture
crossoriginboolean (auto) optional Should use anonymous CORS? Defaults to true if the URL is not a data-URI.
scaleModenumber PIXI.settings.SCALE_MODE optional See PIXI.SCALE_MODES for possible values
sourceScalenumber (auto) optional Scale for the original image, used with Svg images.
Returns:
Type Description PIXI.BaseTexture The new base texture. -
PIXI.BaseTexture.removeFromCache (baseTexture)PIXI.BaseTexture | null static
-
Remove a BaseTexture from the global BaseTextureCache.
Name Type Description baseTexturestring | PIXI.BaseTexture id of a BaseTexture to be removed, or a BaseTexture instance itself.
Returns:
Type Description PIXI.BaseTexture | null The BaseTexture that was removed. -
Checks if
sourceis an SVG image and whether it's loaded via a URL or a data URI. Then calls_loadSvgSourceUsingDataUrior_loadSvgSourceUsingXhr. -
Reads an SVG string from data URI and then calls
_loadSvgSourceUsingString.Name Type Description dataUristring The data uri to load from.
-
Loads texture using an SVG string. The original SVG Image is stored as
origSourceand the created canvas is the newsource. The SVG is scaled usingsourceScale. Called by_loadSvgSourceUsingXhror_loadSvgSourceUsingDataUri.Name Type Description svgStringstring SVG source as string
Fires:
-
Loads an SVG string from
imageUrlusing XHR and then calls_loadSvgSourceUsingString. -
Update dimensions from real values
-
Updates type of the source image.
-
Destroys this base texture
-
Frees the texture from WebGL memory without destroying this texture object. This means you can still use the texture later which will upload it to GPU memory again.
Fires:
-
Load a source.
If the source is not-immediately-available, such as an image that needs to be downloaded, then the 'loaded' or 'error' event will be dispatched in the future and
hasLoadedwill remain false after this call.The logic state after calling
loadSourcedirectly or indirectly (eg.fromImage,new BaseTexture) is:if (texture.hasLoaded) { // texture ready for use } else if (texture.isLoading) { // listen to 'loaded' and/or 'error' events on texture } else { // not loading, not going to load UNLESS the source is reloaded // (it may still make sense to listen to the events) }Name Type Description sourceHTMLImageElement | HTMLCanvasElement the source object of the texture.
-
Updates the texture on all the webgl renderers, this also assumes the src has changed.
Fires:
-
Changes the source image of the texture. The original source must be an Image element.
Name Type Description newSrcstring the path of the image
Events
-
Fired when BaseTexture is destroyed.
Name Type Description baseTexturePIXI.BaseTexture Instance of texture being destroyed.
-
Fired when a not-immediately-available source fails to load.
Name Type Description baseTexturePIXI.BaseTexture Resource errored.
-
Fired when a not-immediately-available source finishes loading.
Name Type Description baseTexturePIXI.BaseTexture Resource loaded.
-
Fired when BaseTexture is updated.
Name Type Description baseTexturePIXI.BaseTexture Instance of texture being updated.