new RenderTexture(width, height, renderer, scaleMode, resolution)
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
Parameters:
Name | Type | Description |
---|---|---|
width |
Number | The width of the render texture |
height |
Number | The height of the render texture |
renderer |
PIXI.CanvasRenderer | PIXI.WebGLRenderer | The renderer used for this RenderTexture |
scaleMode |
Number | See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values |
resolution |
Number | The resolution of the texture being generated |
- Source - pixi/textures/RenderTexture.js, line 5
Extends
Members
-
baseTexture :PIXI.BaseTexture
-
The base texture object that this texture uses
- 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)- Source - pixi/textures/RenderTexture.js, line 69
-
frame :Rectangle
-
The framing rectangle of the render texture
- Source - pixi/textures/RenderTexture.js, line 61
-
height :Number
-
The height of the render texture
- Source - pixi/textures/RenderTexture.js, line 45
-
isTiling :Boolean
-
Is this a tiling texture? As used by the likes of a TilingSprite.
- Inherited From:
- Source - pixi/textures/Texture.js, line 79
-
noFrame :Boolean
-
Does this Texture have any frame data assigned to it?
- Inherited From:
- 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:
- 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:
- 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:
- Source - pixi/textures/Texture.js, line 87
-
resolution :Number
-
The Resolution of the texture.
- Source - pixi/textures/RenderTexture.js, line 53
-
trim :Rectangle
-
The texture trim data.
- Inherited From:
- Source - pixi/textures/Texture.js, line 63
-
valid :Boolean
-
- Source - pixi/textures/RenderTexture.js, line 125
-
width :Number
-
The with of the render texture
- Source - pixi/textures/RenderTexture.js, line 37
Methods
-
clear()
-
Clears the RenderTexture.
- 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:
- 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.
- 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.
- Source - pixi/textures/RenderTexture.js, line 320
-
getImage() → {Image}
-
Will return a HTML Image of the texture
Returns:
Image -- Source - pixi/textures/RenderTexture.js, line 296
-
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?
- 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:
- Source - pixi/textures/Texture.js, line 178