Name | Type | Attributes | Default | Description |
---|---|---|---|---|
resource |
PIXI.Resource | PIXI.ImageSource | string |
<optional> |
null |
The current resource to use, for things that aren't Resource objects, will be converted into a Resource. |
options |
IBaseTextureOptions<RO> | undefined |
Collection of options, default options inherited from PIXI.BaseTexture.defaultOptions. |
|
options.mipmap |
PIXI.MIPMAP_MODES |
<optional> |
If mipmapping is enabled for texture |
|
options.anisotropicLevel |
number |
<optional> |
Anisotropic filtering level of texture |
|
options.wrapMode |
PIXI.WRAP_MODES |
<optional> |
Wrap mode for textures |
|
options.scaleMode |
PIXI.SCALE_MODES |
<optional> |
Default scale mode, linear, nearest |
|
options.format |
PIXI.FORMATS |
<optional> |
GL format type |
|
options.type |
PIXI.TYPES |
<optional> |
GL data type |
|
options.target |
PIXI.TARGETS |
<optional> |
GL texture target |
|
options.alphaMode |
PIXI.ALPHA_MODES |
<optional> |
Pre multiply the image alpha |
|
options.width |
number |
<optional> |
0 |
Width of the texture |
options.height |
number |
<optional> |
0 |
Height of the texture |
options.resolution |
number |
<optional> |
PIXI.settings.RESOLUTION |
Resolution of the base texture |
options.resourceOptions |
object |
<optional> |
Optional resource options, see autoDetectResource |
Extends
- EventEmitter
Members
Global number of the texture batch, used by multi-texture renderers.
- Default Value:
- 0
Default options used when creating BaseTexture objects.
Properties:
Name | Type | Default | Description |
---|---|---|---|
alphaMode |
PIXI.ALPHA_MODES | PIXI.ALPHA_MODES.UNPACK |
Pre multiply the image alpha |
anisotropicLevel |
number | 0 |
Anisotropic filtering level of texture |
format |
PIXI.FORMATS | PIXI.FORMATS.RGBA |
GL format type |
mipmap |
PIXI.MIPMAP_MODES | PIXI.MIPMAP_MODES.POW2 |
If mipmapping is enabled for texture. |
scaleMode |
PIXI.SCALE_MODES | PIXI.SCALE_MODES.LINEAR |
Default scale mode, linear, nearest. |
target |
PIXI.TARGETS | PIXI.TARGETS.TEXTURE_2D |
GL texture target |
type |
PIXI.TYPES | PIXI.TYPES.UNSIGNED_BYTE |
GL data type |
wrapMode |
PIXI.WRAP_MODES | PIXI.WRAP_MODES.CLAMP |
Wrap mode for textures. |
Number of the texture batch, used by multi-texture renderers
Location inside texture batch, used by multi-texture renderers
alphaMode PIXI.ALPHA_MODES
How to treat premultiplied alpha, see PIXI.ALPHA_MODES.
- Default Value:
- PIXI.ALPHA_MODES.UNPACK
Anisotropic filtering level of texture
- Default Value:
- 0
Currently default cache ID.
Flag if BaseTexture has been destroyed.
Used by TextureSystem to only update texture to the GPU when needed.
Please call update()
to increment it.
format PIXI.FORMATS
The pixel format of the texture
- Default Value:
- PIXI.FORMATS.RGBA
The height of the base texture set when the image has loaded
Whether or not the texture is a power of two, try to use power of two textures as much as you can
- Default Value:
- false
mipmap PIXI.MIPMAP_MODES
Mipmap mode of the texture, affects downscaled images
- Default Value:
- PIXI.MIPMAP_MODES.POW2
parentTextureArray PIXI.BaseTexture
Whether its a part of another texture, handled by ArrayResource or CubeResource
Pixel height of the source of this texture
Pixel width of the source of this texture
The resolution / device pixel ratio of the texture
- Default Value:
- PIXI.settings.RESOLUTION
resource PIXI.Resource readonly
The resource used by this BaseTexture, there can only be one resource per BaseTexture, but textures can share resources.
scaleMode PIXI.SCALE_MODES
The scale mode to apply when scaling this texture
- Default Value:
- PIXI.SCALE_MODES.LINEAR
target PIXI.TARGETS
The target type
- Default Value:
- PIXI.TARGETS.TEXTURE_2D
The collection of alternative cache ids, since some BaseTextures can have more than one ID, short name and longer full URL
type PIXI.TYPES
The type of resource data
- Default Value:
- PIXI.TYPES.UNSIGNED_BYTE
Generally speaking means when resource is loaded.
The width of the base texture set when the image has loaded
wrapMode PIXI.WRAP_MODES
How the texture wraps
- Default Value:
- PIXI.WRAP_MODES.CLAMP
Used by TextureSystem to only update texture style when needed.
Used by automatic texture Garbage Collection, stores last GC tick when it was bound
Global unique identifier for this BaseTexture
Methods
Adds a BaseTexture to the global BaseTextureCache. This cache is shared across the whole PIXI object.
Name | Type | Description |
---|---|---|
baseTexture |
PIXI.BaseTexture |
The BaseTexture to add to the cache. |
id |
string |
The id that the BaseTexture will be stored against. |
PIXI.BaseTexture.from (source, options, strict) 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 | Attributes | Default | Description |
---|---|---|---|---|
source |
PIXI.ImageSource | string | Array<string> |
The source to create base texture from. |
||
options |
IBaseTextureOptions<RO> |
<optional> |
See PIXI.BaseTexture's constructor for options. |
|
options.pixiIdPrefix |
string |
<optional> |
pixiid |
If a source has no id, this is the prefix of the generated id |
strict |
boolean |
<optional> |
Enforce strict-mode, see PIXI.settings.STRICT_TEXTURE_CACHE. |
Returns:
Type | Description |
---|---|
PIXI.BaseTexture | The new base texture. |
PIXI.BaseTexture.fromBuffer (buffer, width, height, options) PIXI.BaseTexture<PIXI.BufferResource> static
Create a new Texture with a BufferResource from a typed array.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
buffer |
BufferType |
The optional array to use. If no data is provided, a new Float32Array is created. |
||
width |
number |
Width of the resource |
||
height |
number |
Height of the resource |
||
options |
IBaseTextureOptions<PIXI.IBufferResourceOptions> |
<optional> |
See PIXI.BaseTexture's constructor for options. Default properties are different from the constructor's defaults. |
|
options.format |
PIXI.FORMATS |
<optional> |
The format is not given, the type is inferred from the
type of the buffer: |
|
options.type |
PIXI.TYPES |
<optional> |
The type is not given, the type is inferred from the
type of the buffer. Maps Float32Array to |
|
options.alphaMode |
PIXI.ALPHA_MODES |
<optional> |
PIXI.ALPHA_MODES.NPM | |
options.scaleMode |
PIXI.SCALE_MODES |
<optional> |
PIXI.SCALE_MODES.NEAREST |
Returns:
Type | Description |
---|---|
PIXI.BaseTexture<PIXI.BufferResource> |
|
PIXI.BaseTexture.removeFromCache (baseTexture) PIXI.BaseTexture | unknown static
Remove a BaseTexture from the global BaseTextureCache.
Name | Type | Description |
---|---|---|
baseTexture |
string | PIXI.BaseTexture |
id of a BaseTexture to be removed, or a BaseTexture instance itself. |
Returns:
Type | Description |
---|---|
PIXI.BaseTexture | unknown | The BaseTexture that was removed. |
castToBaseTexture () PIXI.BaseTexture
Utility function for BaseTexture|Texture cast.
Returns:
Type | Description |
---|---|
PIXI.BaseTexture |
Destroys this base texture. The method stops if resource doesn't want this texture to be destroyed. Removes texture from all caches.
Fires:
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:
getDrawableSource () PIXI.ICanvasImageSource
Get the drawable source, such as HTMLCanvasElement or HTMLImageElement suitable for rendering with CanvasRenderer. Provided by @pixi/canvas-renderer package.
Returns:
Type | Description |
---|---|
PIXI.ICanvasImageSource | Source to render with CanvasRenderer |
Sets real size of baseTexture, preserves current resolution.
Name | Type | Attributes | Description |
---|---|---|---|
realWidth |
number |
Full rendered width |
|
realHeight |
number |
Full rendered height |
|
resolution |
number |
<optional> |
Optionally set resolution |
Returns:
Type | Description |
---|---|
this |
|
Changes resolution
Name | Type | Description |
---|---|---|
resolution |
number |
res |
Returns:
Type | Description |
---|---|
this |
|
Sets the resource if it wasn't set. Throws error if resource already present
Name | Type | Description |
---|---|---|
resource |
R |
that is managing this BaseTexture |
Returns:
Type | Description |
---|---|
this |
|
Changes w/h/resolution. Texture becomes valid if width and height are greater than zero.
Name | Type | Attributes | Description |
---|---|---|---|
desiredWidth |
number |
Desired visual width |
|
desiredHeight |
number |
Desired visual height |
|
resolution |
number |
<optional> |
Optionally set resolution |
Returns:
Type | Description |
---|---|
this |
|
Changes style options of BaseTexture
Name | Type | Attributes | Description |
---|---|---|---|
scaleMode |
PIXI.SCALE_MODES |
<optional> |
Pixi scalemode |
mipmap |
PIXI.MIPMAP_MODES |
<optional> |
enable mipmaps |
Returns:
Type | Description |
---|---|
this |
|
Invalidates the object. Texture becomes valid if width and height are greater than zero.
Events
Fired when BaseTexture is destroyed.
Name | Type | Description |
---|---|---|
baseTexture |
PIXI.BaseTexture |
Instance of texture being destroyed. |
Fired when a not-immediately-available source fails to load.
Name | Type | Description |
---|---|---|
baseTexture |
PIXI.BaseTexture |
Resource errored. |
event |
ErrorEvent |
Load error event. |
Fired when a not-immediately-available source finishes loading.
Name | Type | Description |
---|---|---|
baseTexture |
PIXI.BaseTexture |
Resource loaded. |
Fired when BaseTexture is updated.
Name | Type | Description |
---|---|---|
baseTexture |
PIXI.BaseTexture |
Resource loaded. |
Fired when BaseTexture is updated.
Name | Type | Description |
---|---|---|
baseTexture |
PIXI.BaseTexture |
Instance of texture being updated. |