rapid-render
    Preparing search index...

    Class RenderTexture

    A texture that can be rendered to (wraps a WebGL Framebuffer).

    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

    Methods

    • Activates this texture as the current render target.

      Parameters

      • OptionalclearColor: Color

        Optional color to clear the buffer with.

      Returns void

    • Deactivates this texture, returning rendering to the default frame buffer.

      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.

    • Resizes the render texture using a grow-only GPU allocation strategy.

      • GPU memory is only reallocated when the new size exceeds the current allocation.
      • Shrinking only updates the logical dimensions and UV sub-region — no GPU work.

      This makes it safe to call every frame with varying sizes (e.g. inside applyFilters).

      Parameters

      • width: number

        New logical width.

      • height: number

        New logical height.

      • force: boolean = false

        Force full GPU reallocation regardless of current allocation size.

      Returns void

    • 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.

    • 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);