A Texture Source is the encapsulation of the actual source data for a Texture.
This is typically an Image Element, loaded from the file system or network, a Canvas Element or a Video Element.
A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded.
new TextureSource(texture, source, [width], [height], [flipY])
name | type | arguments | Default | description |
---|---|---|---|---|
texture | Phaser.Textures.Texture |
The Texture this TextureSource belongs to. |
||
source | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Phaser.GameObjects.RenderTexture | Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | Phaser.Textures.DynamicTexture | Phaser.Types.Textures.CompressedTextureData |
The source image data. |
||
width | number | <optional> |
Optional width of the source image. If not given it's derived from the source itself. |
|
height | number | <optional> |
Optional height of the source image. If not given it's derived from the source itself. |
|
flipY | boolean | <optional> | false |
Sets the |
Holds the compressed textured algorithm, or null
if it's not a compressed texture.
Prior to Phaser 3.60 this value always held null
.
Sets the UNPACK_FLIP_Y_WEBGL
flag the WebGL Texture uses during upload.
The wrapped WebGL Texture of the source image. If this TextureSource is driven from a WebGLTexture already, then this wrapper contains a reference to that WebGLTexture.
The height of the source image. If not specified in the constructor it will check
the naturalHeight
and then height
properties of the source image.
The image data.
This is either an Image element, Canvas element, Video Element, or Uint8Array.
Is the source image a Canvas Element?
Is the source image a WebGLTextureWrapper?
Are the source image dimensions a power of two?
Is the source image a Render Texture?
Is the source image a Video Element?
A reference to the Canvas or WebGL Renderer.
The resolution of the source image.
The Scale Mode the image will use when rendering. Either Linear or Nearest.
The source of the image data.
This is either an Image Element, a Canvas Element, a Video Element, a RenderTexture or a WebGLTextureWrapper.
In Phaser 3.60 and above it can also be a Compressed Texture data object.
The Texture this TextureSource instance belongs to.
The width of the source image. If not specified in the constructor it will check
the naturalWidth
and then width
properties of the source image.
Destroys this Texture Source and nulls the references.
Creates a WebGL Texture, if required, and sets the Texture filter mode.
name | type | description |
---|---|---|
game | Phaser.Game |
A reference to the Phaser Game instance. |
Sets the Filter Mode for this Texture.
The mode can be either Linear, the default, or Nearest.
For pixel-art you should use Nearest.
name | type | description |
---|---|---|
filterMode | Phaser.Textures.FilterMode |
The Filter Mode. |
Sets the UNPACK_FLIP_Y_WEBGL
flag for the WebGL Texture during texture upload.
name | type | arguments | Default | description |
---|---|---|---|---|
value | boolean | <optional> | true |
Should the WebGL Texture be flipped on the Y axis on texture upload or not? |
If this TextureSource is backed by a Canvas and is running under WebGL, it updates the WebGLTexture using the canvas data.