phaser - v3.90.0
    Preparing search index...

    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.

    Index

    Constructors

    • Parameters

      • texture: Textures.Texture

        The Texture this TextureSource belongs to.

      • source:
            | HTMLCanvasElement
            | DynamicTexture
            | WebGLTextureWrapper
            | GameObjects.RenderTexture
            | HTMLVideoElement
            | HTMLImageElement
            | CompressedTextureData

        The source image data.

      • Optionalwidth: number

        Optional width of the source image. If not given it's derived from the source itself.

      • Optionalheight: number

        Optional height of the source image. If not given it's derived from the source itself.

      • OptionalflipY: boolean

        Sets the UNPACK_FLIP_Y_WEBGL flag the WebGL Texture uses during upload. Default false.

      Returns TextureSource

    Properties

    compressionAlgorithm: number

    Holds the compressed textured algorithm, or null if it's not a compressed texture.

    Prior to Phaser 3.60 this value always held null.

    flipY: boolean

    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.

    height: number

    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.

    image:
        | HTMLCanvasElement
        | Uint8Array<ArrayBuffer>
        | HTMLVideoElement
        | HTMLImageElement

    The image data.

    This is either an Image element, Canvas element, Video Element, or Uint8Array.

    isCanvas: boolean

    Is the source image a Canvas Element?

    isGLTexture: boolean

    Is the source image a WebGLTextureWrapper?

    isPowerOf2: boolean

    Are the source image dimensions a power of two?

    isRenderTexture: boolean

    Is the source image a Render Texture?

    isVideo: boolean

    Is the source image a Video Element?

    A reference to the Canvas or WebGL Renderer.

    resolution: number

    The resolution of the source image.

    scaleMode: number

    The Scale Mode the image will use when rendering. Either Linear or Nearest.

    source:
        | HTMLCanvasElement
        | DynamicTexture
        | WebGLTextureWrapper
        | GameObjects.RenderTexture
        | HTMLVideoElement
        | HTMLImageElement
        | CompressedTextureData

    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.

    texture: Textures.Texture

    The Texture this TextureSource instance belongs to.

    width: number

    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.

    Methods

    • Destroys this Texture Source and nulls the references.

      Returns void

    • Creates a WebGL Texture, if required, and sets the Texture filter mode.

      Parameters

      • game: Game

        A reference to the Phaser Game instance.

      Returns void

    • Sets the Filter Mode for this Texture.

      The mode can be either Linear, the default, or Nearest.

      For pixel-art you should use Nearest.

      Parameters

      Returns void

    • Sets the UNPACK_FLIP_Y_WEBGL flag for the WebGL Texture during texture upload.

      Parameters

      • Optionalvalue: boolean

        Should the WebGL Texture be flipped on the Y axis on texture upload or not? Default true.

      Returns void

    • If this TextureSource is backed by a Canvas and is running under WebGL, it updates the WebGLTexture using the canvas data.

      Returns void