rapid-render
    Preparing search index...

    Class TextTexture

    A texture that renders text using an internal HTML Canvas.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _ph: number = 0
    _pw: number = 0
    _px: number = 0
    _py: number = 0
    base?: BaseTexture
    flipY: boolean = true
    glTexture: WebGLTexture | null = null
    height: number = 0
    padding: number = 0
    scale: number = 1
    uvH: number = 1
    uvW: number = 1
    uvX: number = 0
    uvY: number = 0
    width: number = 0

    Accessors

    • get text(): string

      Returns string

    • set text(value: string): void

      Set new text and update the texture

      Parameters

      • value: string

      Returns void

    Methods

    • Marks this Texture as destroyed, decrementing the BaseTexture reference count.

      Returns void

    • Creates a new Texture representing a sub-region of this Texture.

      Parameters

      • x: number

        The x coordinate in pixels, relative to this texture's logical start.

      • y: number

        The y coordinate in pixels, relative to this texture's logical start.

      • width: number

        The width of the sub-texture in pixels.

      • height: number

        The height of the sub-texture in pixels.

      Returns Texture

      A new Texture pointing to the sub-region.

    • Sets the base texture and increments its reference count.

      Parameters

      • base: BaseTexture

        The BaseTexture instance.

      Returns this

      The current Texture instance.

    • Sets the visible region (clipping) in pixels relative to the BaseTexture.

      Parameters

      • x: number

        The x coordinate in pixels.

      • y: number

        The y coordinate in pixels.

      • w: number

        The width in pixels.

      • h: number

        The height in pixels.

      Returns this

      The current Texture instance.

    • Utility to split this texture into a grid of sprite textures. Sub-textures will respect the current UV offsets.

      Parameters

      • cellWidth: number

        The width of each cell in pixels.

      • cellHeight: number

        The height of each cell in pixels.

      • Optionalcols: number

        Optional number of columns. Truncates based on texture width if omitted.

      • Optionalrows: number

        Optional number of rows. Truncates based on texture height if omitted.

      Returns Texture[]

      An array of split Textures.

    • Updates the internal canvas and uploads it to WebGL

      Returns void

    • Returns a new Texture with the rendered quad expanded by pixels on all sides. The UV coordinates are adjusted outward so the padded border samples outside the original texture region (which is transparent when using CLAMP wrap mode).

      Use this with outline or glow shaders that need to draw beyond the texture edge.

      Parameters

      • pixels: number

        Number of pixels to expand on each side.

      Returns Texture

      const padded = catTex.withPadding(6);
      rapid.drawSprite(padded, Color.White(), false, false, outlineShader);