## Phaser. RenderTexture

#### new RenderTexture(game, width, height, key, scaleMode, resolution)

  A RenderTexture is a special texture that allows any displayObject to be rendered to it. It allows you to take many complex objects and
  render them down into a single quad (on WebGL) which can then be used to texture other display objects with. A way of generating textures at run-time.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `game` | Phaser.Game |  |  | Current game instance.
  `width` | number | <optional> | 100 | The width of the render texture.
  `height` | number | <optional> | 100 | The height of the render texture.
  `key` | string | <optional> | '' | The key of the RenderTexture in the Cache, if stored there.
  `scaleMode` | number | <optional> | Phaser.scaleModes.DEFAULT | One of the Phaser.scaleModes consts.
  `resolution` | number | <optional> | 1 | The resolution of the texture being generated.

  Source - gameobjects/RenderTexture.js, line 21

### Extends

- PIXI.RenderTexture

### Members

#### baseTexture :PIXI.BaseTexture

  The base texture object that this texture uses

  Inherited From:
    - PIXI.RenderTexture#baseTexture
  Source - pixi/textures/RenderTexture.js, line 78

#### crop :Rectangle

  This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering,
  irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases)

  Inherited From:
    - PIXI.RenderTexture#crop
  Source - pixi/textures/RenderTexture.js, line 69

#### frame :Rectangle

  The framing rectangle of the render texture

  Inherited From:
    - PIXI.RenderTexture#frame
  Source - pixi/textures/RenderTexture.js, line 61

#### game :Phaser.Game

  A reference to the currently running game.

  Source - gameobjects/RenderTexture.js, line 30

#### height :Number

  The height of the render texture

  Inherited From:
    - PIXI.RenderTexture#height
  Source - pixi/textures/RenderTexture.js, line 45

#### isTiling :Boolean

  Is this a tiling texture? As used by the likes of a TilingSprite.

  Inherited From:
    - PIXI.Texture#isTiling
  Source - pixi/textures/Texture.js, line 79

#### key :string

  The key of the RenderTexture in the Cache, if stored there.

  Source - gameobjects/RenderTexture.js, line 35

#### noFrame :Boolean

  Does this Texture have any frame data assigned to it?

  Inherited From:
    - PIXI.Texture#noFrame
  Source - pixi/textures/Texture.js, line 28

#### renderer :PIXI.CanvasRenderer|PIXI.WebGLRenderer

  The renderer this RenderTexture uses. A RenderTexture can only belong to one renderer at the moment if its webGL.

  ##### Type:

  - PIXI.CanvasRenderer | PIXI.WebGLRenderer
  Inherited From:
    - PIXI.RenderTexture#renderer
  Source - pixi/textures/RenderTexture.js, line 99

#### requiresReTint :Boolean

  This will let a renderer know that a tinted parent has updated its texture.

  Inherited From:
    - PIXI.Texture#requiresReTint
  Source - pixi/textures/Texture.js, line 95

#### requiresUpdate :Boolean

  This will let a renderer know that a texture has been updated (used mainly for webGL uv updates)

  Inherited From:
    - PIXI.Texture#requiresUpdate
  Source - pixi/textures/Texture.js, line 87

#### resolution :Number

  The Resolution of the texture.

  Inherited From:
    - PIXI.RenderTexture#resolution
  Source - pixi/textures/RenderTexture.js, line 53

#### trim :Rectangle

  The texture trim data.

  Inherited From:
    - PIXI.Texture#trim
  Source - pixi/textures/Texture.js, line 63

#### type :number

  Base Phaser object type.

  Source - gameobjects/RenderTexture.js, line 40

#### valid :Boolean

  Inherited From:
    - PIXI.RenderTexture#valid
  Source - pixi/textures/RenderTexture.js, line 125

#### width :Number

  The with of the render texture

  Inherited From:
    - PIXI.RenderTexture#width
  Source - pixi/textures/RenderTexture.js, line 37

### Methods

#### clear()

  Clears the RenderTexture.

  Inherited From:
    - PIXI.RenderTexture#clear
  Source - pixi/textures/RenderTexture.js, line 175

#### destroy(destroyBase)

  Destroys this texture

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `destroyBase` | Boolean | Whether to destroy the base texture as well

  Inherited From:
    - PIXI.Texture#destroy
  Source - pixi/textures/Texture.js, line 165

#### getBase64() → {String}

  Will return a base64 encoded string of this texture. It works by calling RenderTexture.getCanvas and then running toDataURL on that.

  ##### Returns:

  String -

  A base64 encoded string of the texture.

  Inherited From:
    - PIXI.RenderTexture#getBase64
  Source - pixi/textures/RenderTexture.js, line 309

#### getCanvas() → {HTMLCanvasElement}

  Creates a Canvas element, renders this RenderTexture to it and then returns it.

  ##### Returns:

  HTMLCanvasElement -

  A Canvas element with the texture rendered on.

  Inherited From:
    - PIXI.RenderTexture#getCanvas
  Source - pixi/textures/RenderTexture.js, line 320

#### getImage() → {Image}

  Will return a HTML Image of the texture

  ##### Returns:

  Image -
  Inherited From:
    - PIXI.RenderTexture#getImage
  Source - pixi/textures/RenderTexture.js, line 296

#### render(displayObject, matrix, clear)

  This function will draw the display object to the RenderTexture.

  In versions of Phaser prior to 2.4.0 the second parameter was a Phaser.Point object.
  This is now a Matrix allowing you much more control over how the Display Object is rendered.
  If you need to replicate the earlier behavior please use Phaser.RenderTexture.renderXY instead.

  If you wish for the displayObject to be rendered taking its current scale, rotation and translation into account then either
  pass `null`, leave it undefined or pass `displayObject.worldTransform` as the matrix value.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `displayObject` | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Group |  |  | The display object to render to this texture.
  `matrix` | Phaser.Matrix | <optional> |  | Optional matrix to apply to the display object before rendering. If null or undefined it will use the worldTransform matrix of the given display object.
  `clear` | boolean | <optional> | false | If true the texture will be cleared before the display object is drawn.

  Source - gameobjects/RenderTexture.js, line 117

#### renderRawXY(displayObject, x, y, clear)

  This function will draw the display object to the RenderTexture at the given coordinates.

  When the display object is drawn it doesn't take into account scale, rotation or translation.

  If you need those then use RenderTexture.renderXY instead.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `displayObject` | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Group |  |  | The display object to render to this texture.
  `x` | number |  |  | The x position to render the object at.
  `y` | number |  |  | The y position to render the object at.
  `clear` | boolean | <optional> | false | If true the texture will be cleared before the display object is drawn.

  Source - gameobjects/RenderTexture.js, line 89

#### renderXY(displayObject, x, y, clear)

  This function will draw the display object to the RenderTexture at the given coordinates.

  When the display object is drawn it takes into account scale and rotation.

  If you don't want those then use RenderTexture.renderRawXY instead.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `displayObject` | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Group |  |  | The display object to render to this texture.
  `x` | number |  |  | The x position to render the object at.
  `y` | number |  |  | The y position to render the object at.
  `clear` | boolean | <optional> | false | If true the texture will be cleared before the display object is drawn.

  Source - gameobjects/RenderTexture.js, line 57

#### resize(width, height, updateBase)

  Resizes the RenderTexture.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `width` | Number | The width to resize to.
  `height` | Number | The height to resize to.
  `updateBase` | Boolean | Should the baseTexture.width and height values be resized as well?

  Inherited From:
    - PIXI.RenderTexture#resize
  Source - pixi/textures/RenderTexture.js, line 139

#### setFrame(frame)

  Specifies the region of the baseTexture that this texture will use.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `frame` | Rectangle | The frame of the texture to set it to

  Inherited From:
    - PIXI.Texture#setFrame
  Source - pixi/textures/Texture.js, line 178