pixi.js/docs/classes/RenderTexture.html
2013-06-24 15:32:52 +01:00

795 lines
19 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>RenderTexture - Pixi.JS</title>
<link rel="stylesheet" href="http:&#x2F;&#x2F;yui.yahooapis.com&#x2F;3.8.0&#x2F;build&#x2F;cssgrids&#x2F;cssgrids-min.css">
<link rel="stylesheet" href="..&#x2F;assets/vendor/prettify/prettify-min.css">
<link rel="stylesheet" href="..&#x2F;assets/css/main.css" id="site_styles">
<link rel="shortcut icon" type="image/png" href="..&#x2F;assets/favicon.png">
<script src="http:&#x2F;&#x2F;yui.yahooapis.com&#x2F;combo?3.8.0&#x2F;build&#x2F;yui&#x2F;yui-min.js"></script>
</head>
<body class="yui3-skin-sam">
<div id="doc">
<div id="hd" class="yui3-g header">
<div class="yui3-u-3-4">
<h1><img src="http:&#x2F;&#x2F;www.goodboydigital.com&#x2F;pixijs&#x2F;logo_small.png" title="Pixi.JS"></h1>
</div>
<div class="yui3-u-1-4 version">
<em>API Docs for: 1.3.0</em>
</div>
</div>
<div id="bd" class="yui3-g">
<div class="yui3-u-1-4">
<div id="docs-sidebar" class="sidebar apidocs">
<div id="api-list">
<h2 class="off-left">APIs</h2>
<div id="api-tabview" class="tabview">
<ul class="tabs">
<li><a href="#api-classes">Classes</a></li>
<li><a href="#api-modules">Modules</a></li>
</ul>
<div id="api-tabview-filter">
<input type="search" id="api-filter" placeholder="Type to filter APIs">
</div>
<div id="api-tabview-panel">
<ul id="api-classes" class="apis classes">
<li><a href="..&#x2F;classes/AssetLoader.html">AssetLoader</a></li>
<li><a href="..&#x2F;classes/BaseTexture.html">BaseTexture</a></li>
<li><a href="..&#x2F;classes/BitmapFontLoader.html">BitmapFontLoader</a></li>
<li><a href="..&#x2F;classes/BitmapText.html">BitmapText</a></li>
<li><a href="..&#x2F;classes/CanvasGraphics.html">CanvasGraphics</a></li>
<li><a href="..&#x2F;classes/CanvasRenderer.html">CanvasRenderer</a></li>
<li><a href="..&#x2F;classes/CustomRenderable.html">CustomRenderable</a></li>
<li><a href="..&#x2F;classes/DisplayObject.html">DisplayObject</a></li>
<li><a href="..&#x2F;classes/DisplayObjectContainer.html">DisplayObjectContainer</a></li>
<li><a href="..&#x2F;classes/Graphics.html">Graphics</a></li>
<li><a href="..&#x2F;classes/ImageLoader.html">ImageLoader</a></li>
<li><a href="..&#x2F;classes/InteractionData.html">InteractionData</a></li>
<li><a href="..&#x2F;classes/InteractionManager.html">InteractionManager</a></li>
<li><a href="..&#x2F;classes/JsonLoader.html">JsonLoader</a></li>
<li><a href="..&#x2F;classes/MovieClip.html">MovieClip</a></li>
<li><a href="..&#x2F;classes/Point.html">Point</a></li>
<li><a href="..&#x2F;classes/Polygon.html">Polygon</a></li>
<li><a href="..&#x2F;classes/Rectangle.html">Rectangle</a></li>
<li><a href="..&#x2F;classes/RenderTexture.html">RenderTexture</a></li>
<li><a href="..&#x2F;classes/Spine.html">Spine</a></li>
<li><a href="..&#x2F;classes/Sprite.html">Sprite</a></li>
<li><a href="..&#x2F;classes/SpriteSheetLoader.html">SpriteSheetLoader</a></li>
<li><a href="..&#x2F;classes/Stage.html">Stage</a></li>
<li><a href="..&#x2F;classes/Text.html">Text</a></li>
<li><a href="..&#x2F;classes/Texture.html">Texture</a></li>
<li><a href="..&#x2F;classes/TilingSprite.html">TilingSprite</a></li>
<li><a href="..&#x2F;classes/WebGLBatch.html">WebGLBatch</a></li>
<li><a href="..&#x2F;classes/WebGLRenderer.html">WebGLRenderer</a></li>
</ul>
<ul id="api-modules" class="apis modules">
<li><a href="..&#x2F;modules/PIXI.html">PIXI</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="yui3-u-3-4">
<div id="api-options">
Show:
<label for="api-show-inherited">
<input type="checkbox" id="api-show-inherited" checked>
Inherited
</label>
<label for="api-show-protected">
<input type="checkbox" id="api-show-protected">
Protected
</label>
<label for="api-show-private">
<input type="checkbox" id="api-show-private">
Private
</label>
<label for="api-show-deprecated">
<input type="checkbox" id="api-show-deprecated">
Deprecated
</label>
</div>
<div class="apidocs">
<div id="docs-main">
<div class="content">
<h1>RenderTexture Class</h1>
<div class="box meta">
<div class="extends">
Extends <a href="../classes/Texture.html" class="crosslink">Texture</a>
</div>
<div class="foundat">
Defined in: <a href="..&#x2F;files&#x2F;src_pixi_textures_RenderTexture.js.html#l5"><code>src&#x2F;pixi&#x2F;textures&#x2F;RenderTexture.js:5</code></a>
</div>
Module: <a href="../modules/PIXI.html">PIXI</a>
</div>
<div class="box intro">
<p>A RenderTexture is a special texture that allows any pixi displayObject to be rendered to it.</p>
<p><strong>Hint</strong>: All DisplayObjects (exmpl. Sprites) that renders on RenderTexture should be preloaded.
Otherwise black rectangles will be drawn instead. </p>
<p>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:</p>
<pre class="code prettyprint"><code>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);
</code></pre>
<p>Sprite in this case will be rendered to 0,0 position. To render this sprite at center DisplayObjectContainer should be used:</p>
<pre class="code prettyprint"><code>var doc = new PIXI.DisplayObjectContainer();
doc.addChild(sprite);
renderTexture.render(doc); // Renders to center of renderTexture
</code></pre>
</div>
<div class="constructor">
<h2>Constructor</h2>
<div id="method_RenderTexture" class="method item">
<h3 class="name"><code>RenderTexture</code></h3>
<div class="args">
<span class="paren">(</span><ul class="args-list inline commas">
<li class="arg">
<code>width</code>
</li>
<li class="arg">
<code>height</code>
</li>
</ul><span class="paren">)</span>
</div>
<div class="meta">
<p>
Defined in
<a href="..&#x2F;files&#x2F;src_pixi_textures_RenderTexture.js.html#l5"><code>src&#x2F;pixi&#x2F;textures&#x2F;RenderTexture.js:5</code></a>
</p>
</div>
<div class="description">
</div>
<div class="params">
<h4>Parameters:</h4>
<ul class="params-list">
<li class="param">
<code class="param-name">width</code>
<span class="type">Number</span>
<div class="param-description">
</div>
</li>
<li class="param">
<code class="param-name">height</code>
<span class="type">Number</span>
<div class="param-description">
</div>
</li>
</ul>
</div>
</div>
</div>
<div id="classdocs" class="tabview">
<ul class="api-class-tabs">
<li class="api-class-tab index"><a href="#index">Index</a></li>
<li class="api-class-tab methods"><a href="#methods">Methods</a></li>
<li class="api-class-tab properties"><a href="#properties">Properties</a></li>
</ul>
<div>
<div id="index" class="api-class-tabpanel index">
<h2 class="off-left">Item Index</h2>
<div class="index-section methods">
<h3>Methods</h3>
<ul class="index-list methods extends">
<li class="index-item method inherited">
<a href="#method_fromFrame">fromFrame</a>
</li>
<li class="index-item method">
<a href="#method_render">render</a>
</li>
<li class="index-item method inherited">
<a href="#method_setFrame">setFrame</a>
</li>
</ul>
</div>
<div class="index-section properties">
<h3>Properties</h3>
<ul class="index-list properties extends">
<li class="index-item property inherited">
<a href="#property_baseTexture">baseTexture</a>
</li>
<li class="index-item property inherited">
<a href="#property_frame">frame</a>
</li>
</ul>
</div>
</div>
<div id="methods" class="api-class-tabpanel">
<h2 class="off-left">Methods</h2>
<div id="method_fromFrame" class="method item inherited">
<h3 class="name"><code>fromFrame</code></h3>
<div class="args">
<span class="paren">(</span><ul class="args-list inline commas">
<li class="arg">
<code>frameId</code>
</li>
</ul><span class="paren">)</span>
</div>
<span class="returns-inline">
<span class="type"></span>
</span>
<div class="meta">
<p>Inherited from
<a href="..&#x2F;classes&#x2F;Texture.html#method_fromFrame">Texture</a>:
<a href="..&#x2F;files&#x2F;src_pixi_textures_Texture.js.html#l127"><code>src&#x2F;pixi&#x2F;textures&#x2F;Texture.js:127</code></a>
</p>
</div>
<div class="description">
<p>Helper function that returns a texture based on a frame id
If the frame id is not in the texture cache an error will be thrown</p>
</div>
<div class="params">
<h4>Parameters:</h4>
<ul class="params-list">
<li class="param">
<code class="param-name">frameId</code>
<span class="type">String</span>
<div class="param-description">
<p>The frame id of the texture</p>
</div>
</li>
</ul>
</div>
<div class="returns">
<h4>Returns:</h4>
<div class="returns-description">
Texture
</div>
</div>
</div>
<div id="method_render" class="method item">
<h3 class="name"><code>render</code></h3>
<div class="args">
<span class="paren">(</span><ul class="args-list inline commas">
<li class="arg">
<code>displayObject</code>
</li>
<li class="arg">
<code>clear</code>
</li>
</ul><span class="paren">)</span>
</div>
<div class="meta">
<p>
Defined in
<a href="..&#x2F;files&#x2F;src_pixi_textures_RenderTexture.js.html#l112"><code>src&#x2F;pixi&#x2F;textures&#x2F;RenderTexture.js:112</code></a>
</p>
</div>
<div class="description">
<p>This function will draw the display object to the texture.</p>
</div>
<div class="params">
<h4>Parameters:</h4>
<ul class="params-list">
<li class="param">
<code class="param-name">displayObject</code>
<span class="type"><a href="../classes/DisplayObject.html" class="crosslink">DisplayObject</a></span>
<div class="param-description">
</div>
</li>
<li class="param">
<code class="param-name">clear</code>
<span class="type">Boolean</span>
<div class="param-description">
<p>If true the texture will be cleared before the displayObject is drawn</p>
</div>
</li>
</ul>
</div>
</div>
<div id="method_setFrame" class="method item inherited">
<h3 class="name"><code>setFrame</code></h3>
<div class="args">
<span class="paren">(</span><ul class="args-list inline commas">
<li class="arg">
<code>frame</code>
</li>
</ul><span class="paren">)</span>
</div>
<div class="meta">
<p>Inherited from
<a href="..&#x2F;classes&#x2F;Texture.html#method_setFrame">Texture</a>:
<a href="..&#x2F;files&#x2F;src_pixi_textures_Texture.js.html#l83"><code>src&#x2F;pixi&#x2F;textures&#x2F;Texture.js:83</code></a>
</p>
</div>
<div class="description">
<p>Specifies the rectangle region of the baseTexture</p>
</div>
<div class="params">
<h4>Parameters:</h4>
<ul class="params-list">
<li class="param">
<code class="param-name">frame</code>
<span class="type"><a href="../classes/Rectangle.html" class="crosslink">Rectangle</a></span>
<div class="param-description">
</div>
</li>
</ul>
</div>
</div>
</div>
<div id="properties" class="api-class-tabpanel">
<h2 class="off-left">Properties</h2>
<div id="property_baseTexture" class="property item inherited">
<h3 class="name"><code>baseTexture</code></h3>
<span class="type"><a href="../classes/BaseTexture.html" class="crosslink">BaseTexture</a></span>
<div class="meta">
<p>Inherited from
<a href="..&#x2F;classes&#x2F;Texture.html#property_baseTexture">Texture</a>:
<a href="..&#x2F;files&#x2F;src_pixi_textures_Texture.js.html#l31"><code>src&#x2F;pixi&#x2F;textures&#x2F;Texture.js:31</code></a>
</p>
</div>
<div class="description">
<p>The base texture of this texture</p>
</div>
</div>
<div id="property_frame" class="property item inherited">
<h3 class="name"><code>frame</code></h3>
<span class="type">#Rectangle</span>
<div class="meta">
<p>Inherited from
<a href="..&#x2F;classes&#x2F;Texture.html#property_frame">Texture</a>:
<a href="..&#x2F;files&#x2F;src_pixi_textures_Texture.js.html#l40"><code>src&#x2F;pixi&#x2F;textures&#x2F;Texture.js:40</code></a>
</p>
</div>
<div class="description">
<p>The frame specifies the region of the base texture that this texture uses</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="..&#x2F;assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="..&#x2F;assets/js/yui-prettify.js"></script>
<script src="..&#x2F;assets/../api.js"></script>
<script src="..&#x2F;assets/js/api-filter.js"></script>
<script src="..&#x2F;assets/js/api-list.js"></script>
<script src="..&#x2F;assets/js/api-search.js"></script>
<script src="..&#x2F;assets/js/apidocs.js"></script>
</body>
</html>