Options
All
  • Public
  • Public/Protected
  • All
Menu

A BaseRenderTexture is a special texture that allows any PixiJS display object to be rendered to it.

Hint: All DisplayObjects (i.e. Sprites) that render to a BaseRenderTexture should be preloaded otherwise black rectangles will be drawn instead.

A BaseRenderTexture takes a snapshot of any Display Object given to its render method. The position and rotation of the given Display Objects is ignored. For example:

let renderer = PIXI.autoDetectRenderer();
let baseRenderTexture = new PIXI.BaseRenderTexture({ width: 800, height: 600 });
let renderTexture = new PIXI.RenderTexture(baseRenderTexture);
let sprite = PIXI.Sprite.from("spinObj_01.png");

sprite.position.x = 800/2;
sprite.position.y = 600/2;
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;

renderer.render(sprite, {renderTexture});

The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0 you can clear the transform


sprite.setTransform()

let baseRenderTexture = new PIXI.BaseRenderTexture({ width: 100, height: 100 });
let renderTexture = new PIXI.RenderTexture(baseRenderTexture);

renderer.render(sprite, {renderTexture});  // Renders to center of RenderTexture
memberof

PIXI

Hierarchy

Index

Constructors

constructor

Properties

_batchEnabled

_batchEnabled: number

_batchLocation

_batchLocation: number

_canvasRenderTarget

_canvasRenderTarget: CanvasRenderTarget

_glTextures

_glTextures: {}

Type declaration

Optional alphaMode

alphaMode: ALPHA_MODES

Optional anisotropicLevel

anisotropicLevel: number

cacheId

cacheId: string

clearColor

clearColor: number[]

destroyed

destroyed: boolean

dirtyId

dirtyId: number

dirtyStyleId

dirtyStyleId: number

filterStack

filterStack: any[]

Optional format

format: FORMATS

framebuffer

framebuffer: Framebuffer

height

height: number

isPowerOfTwo

isPowerOfTwo: boolean

maskStack

maskStack: MaskData[]

Optional mipmap

mipmap: MIPMAP_MODES

parentTextureArray

resolution

resolution: number

resource

resource: Resource

Optional scaleMode

scaleMode: SCALE_MODES

Optional target

target: TARGETS

textureCacheIds

textureCacheIds: string[]

touched

touched: number

Optional type

type: TYPES

Readonly uid

uid: number

valid

valid: boolean

width

width: number

Optional wrapMode

wrapMode: WRAP_MODES

Static _globalBatch

_globalBatch: number

Global number of the texture batch, used by multi-texture renderers

static
member

{number}

Static prefixed

prefixed: string | boolean

Accessors

realHeight

  • get realHeight(): number
  • Pixel height of the source of this texture

    readonly
    member

    {number}

    Returns number

realWidth

  • get realWidth(): number
  • Pixel width of the source of this texture

    readonly
    member

    {number}

    Returns number

Methods

Private _refreshPOT

  • _refreshPOT(): void
  • Refresh check for isPowerOfTwo texture based on size

    Returns void

addListener

castToBaseTexture

destroy

  • destroy(): void
  • Destroys this texture.

    Returns void

dispose

  • dispose(): void
  • Frees the texture and framebuffer 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

    PIXI.BaseTexture#dispose

    Returns void

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Calls each of the listeners registered for a given event.

    Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): (string | symbol)[]
  • Return an array listing the events for which the emitter has registered listeners.

    Returns (string | symbol)[]

Optional getDrawableSource

  • getDrawableSource(): CanvasImageSource

listenerCount

  • listenerCount(event: string | symbol): number
  • Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

listeners

  • Return the listeners registered for a given event.

    Parameters

    • event: string | symbol

    Returns ListenerFn[]

off

  • Parameters

    • event: string | symbol
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns BaseRenderTexture

on

  • Add a listener for a given event.

    Parameters

    • event: string | symbol
    • fn: ListenerFn
    • Optional context: any

    Returns BaseRenderTexture

Private onError

  • onError(event: ErrorEvent): void
  • Handle errors with resources.

    Parameters

    • event: ErrorEvent

      Error event emitted.

    Returns void

once

  • Add a one-time listener for a given event.

    Parameters

    • event: string | symbol
    • fn: ListenerFn
    • Optional context: any

    Returns BaseRenderTexture

removeAllListeners

  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: string | symbol

    Returns BaseRenderTexture

removeListener

  • Remove the listeners of a given event.

    Parameters

    • event: string | symbol
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns BaseRenderTexture

resize

  • resize(width: number, height: number): void
  • Resizes the BaseRenderTexture.

    Parameters

    • width: number

      The width to resize to.

    • height: number

      The height to resize to.

    Returns void

setRealSize

  • setRealSize(realWidth: number, realHeight: number, resolution?: number): BaseRenderTexture
  • Sets real size of baseTexture, preserves current resolution.

    Parameters

    • realWidth: number

      Full rendered width

    • realHeight: number

      Full rendered height

    • Optional resolution: number

    Returns BaseRenderTexture

    this

setResolution

setResource

  • Sets the resource if it wasn't set. Throws error if resource already present

    Parameters

    • resource: Resource

      that is managing this BaseTexture

    Returns BaseRenderTexture

    this

setSize

  • Changes w/h/resolution. Texture becomes valid if width and height are greater than zero.

    Parameters

    • width: number

      Visual width

    • height: number

      Visual height

    • Optional resolution: number

    Returns BaseRenderTexture

    this

setStyle

update

  • update(): void
  • Invalidates the object. Texture becomes valid if width and height are greater than zero.

    Returns void

Static addToCache

  • Adds a BaseTexture to the global BaseTextureCache. This cache is shared across the whole PIXI object.

    static

    Parameters

    Returns void

Static from

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

    static

    Type parameters

    Parameters

    Returns BaseTexture<R, IAutoDetectOptions>

    The new base texture.

Static fromBuffer

  • Create a new BaseTexture with a BufferResource from a Float32Array. RGBA values are floats from 0 to 1.

    static

    Parameters

    • buffer: Float32Array | Uint8Array

      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

    • Optional options: IBaseTextureOptions<any>

    Returns BaseTexture<BufferResource, IAutoDetectOptions>

    The resulting new BaseTexture

Static removeFromCache

Generated using TypeDoc