#

API Docs for: 1.4.3
Show: Inherited Protected Private Deprecated

# RenderTexture Class

Extends Texture
Defined in: `src/pixi/textures/RenderTexture.js:5`
Module: PIXI

A RenderTexture is a special texture that allows any pixi displayObject to be rendered to it.

Hint: All DisplayObjects (exmpl. Sprites) that render on RenderTexture should be preloaded. Otherwise black rectangles will be drawn instead.

RenderTexture takes snapshot of DisplayObject passed to render method. If DisplayObject is passed to render method, position and rotation of it will be ignored. For example:

var renderTexture = new PIXI.RenderTexture(800, 600); var sprite = PIXI.Sprite.fromImage("spinObj_01.png"); sprite.position.x = 800/2; sprite.position.y = 600/2; sprite.anchor.x = 0.5; sprite.anchor.y = 0.5; renderTexture.render(sprite);

Sprite in this case will be rendered to 0,0 position. To render this sprite at center DisplayObjectContainer should be used:

var doc = new PIXI.DisplayObjectContainer(); doc.addChild(sprite); renderTexture.render(doc); // Renders to center of renderTexture

## Constructor

### `RenderTexture`

(

- `width`
- `height`

)

Defined in `src/pixi/textures/RenderTexture.js:5`

#### Parameters:

- `width` Number

  The width of the render texture

- `height` Number

  The height of the render texture

- Index
- Methods
- Properties

## Item Index

### Methods

- destroy
- onBaseTextureLoaded
- renderCanvas
- renderWebGL
- setFrame

### Properties

- baseTexture
- frame
- trim

## Methods

### `destroy`

(

- `destroyBase`

)

Inherited from Texture: `src/pixi/textures/Texture.js:93`

Destroys this texture

#### Parameters:

- `destroyBase` Boolean

  Whether to destroy the base texture as well

### `onBaseTextureLoaded`

(

- `event`

)
private

Inherited from Texture: `src/pixi/textures/Texture.js:74`

Called when the base texture is loaded

#### Parameters:

- `event` Object

### `renderCanvas`

(

- `displayObject`
- `clear`

)
private

Defined in `src/pixi/textures/RenderTexture.js:153`

This function will draw the display object to the texture.

#### Parameters:

- `displayObject` DisplayObject

  The display object to render this texture on

- `clear` Boolean

  If true the texture will be cleared before the displayObject is drawn

### `renderWebGL`

(

- `displayObject`
- `clear`

)
private

Defined in `src/pixi/textures/RenderTexture.js:102`

This function will draw the display object to the texture.

#### Parameters:

- `displayObject` DisplayObject

  The display object to render this texture on

- `clear` Boolean

  If true the texture will be cleared before the displayObject is drawn

### `setFrame`

(

- `frame`

)

Inherited from Texture: `src/pixi/textures/Texture.js:104`

Specifies the rectangle region of the baseTexture

#### Parameters:

- `frame` Rectangle

  The frame of the texture to set it to

## Properties

### `baseTexture`

BaseTexture

Inherited from Texture: `src/pixi/textures/Texture.js:33`

The base texture of this texture

### `frame`

Rectangle

Inherited from Texture: `src/pixi/textures/Texture.js:41`

The frame specifies the region of the base texture that this texture uses

### `trim`

Point

Inherited from Texture: `src/pixi/textures/Texture.js:49`

The trim point