pixi.textures.RenderTexture

type
class
extends
Texture
metadata
:native
"PIXI.RenderTexture"

Constructor

new(?width : Float, ?height : Float, ?renderer : pixi.renderers.webgl.WebGLRenderer, ?scaleMode : Int, ?resolution : Float)
parameters
[width] {Float} The width of the render texture
[height] {Float} The height of the render texture
[renderer] {CanvasRenderer|WebGLRenderer} The renderer used for this RenderTexture
[scaleMode] {Int} Should be one of the PIXI.scaleMode consts
[resolution] {Float} The resolution of the texture being generated
A RenderTexture is a special texture that allows any Pixi display object to be rendered to it. __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded otherwise black rectangles will be drawn instead. A RenderTexture 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: 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); The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual position a DisplayObjectContainer should be used: var doc = new PIXI.DisplayObjectContainer(); doc.addChild(sprite); renderTexture.render(doc); // Renders to center of renderTexture

Instance Variables hide inherited show inherited

baseTexture : BaseTexture

inherited from pixi.textures.Texture
The base texture that this texture uses.
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)
The frame specifies the region of the base texture that this texture uses

height : Float

inherited from pixi.textures.Texture
The height of the Texture in pixels.

noFrame : Bool

inherited from pixi.textures.Texture
Does this Texture have any frame data assigned to it?

renderer : Dynamic

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

resolution : Float

The Resolution of the texture.
The trim point

uvs : Dynamic

inherited from pixi.textures.Texture
The WebGL UV data cache.

valid : Bool

inherited from pixi.textures.Texture
This will let the renderer know if the texture is valid. If its not then it cannot be rendered.

width : Float

inherited from pixi.textures.Texture
The width of the Texture in pixels.

Instance Methods hide inherited show inherited

clear() : Void

Clears the RenderTexture.

destroy(?destroyBase : Bool) : Void

inherited from pixi.textures.Texture
parameters
destroyBase {Bool} Whether to destroy the base texture as well
Destroys this texture

getBase64() : String

returns
{String} A base64 encoded string of the texture.
Will return a a base64 encoded string of this texture. It works by calling RenderTexture.getCanvas and then running toDataURL on that.

getCanvas() : pixi.CanvasElement

returns
{CanvasElement} A Canvas element with the texture rendered on.
Creates a Canvas element, renders this RenderTexture to it and then returns it.

getImage() : pixi.Image

returns
{HTMLImage}
Will return a HTML Image of the texture

render(displayObject : pixi.display.DisplayObject, matrix : pixi.geom.Matrix, clear : Bool) : Void

parameters
displayObject {DisplayObject} The display object to render this texture on
[matrix] {Matrix} Optional matrix to apply to the display object before rendering.
[clear] {Bool} If true the texture will be cleared before the displayObject is drawn
This function will draw the display object to the texture.

resize(width : Float, height : Float, ?updateBase : Bool) : Void

parameters
width {Float} The width to resize to.
height {Float} The height to resize to.
[updateBase] {Bool} Should the baseTexture.width and height values be resized as well?
Resize the RenderTexture.