Difference between revisions of "RenderTarget"

From GiderosMobile
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''Supported platforms:''' <br/>
+
<!-- GIDEROSOBJ:RenderTarget -->
 +
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
 
'''Available since:''' Gideros 2013.06<br/>
 
'''Available since:''' Gideros 2013.06<br/>
=== <translate>Description</translate> ===
+
'''Inherits from:''' [[TextureBase]]<br/>
<translate>RenderTarget is a texture on which provided Sprite hierarchy can be rendered.
+
 
It can be used in any case in which Texture can be used.</translate>
+
=== Description ===
=== <translate>Examples</translate> ===
+
RenderTarget is a texture on which provided Sprite hierarchy can be rendered.
'''Using as texture and updating RenderTarget'''<br/>
+
 
<source lang="lua">--original bitmap
+
It can be used in any case in which Texture can be used.
 +
 
 +
=== Example ===
 +
'''Using a texture and updating RenderTarget'''
 +
<syntaxhighlight lang="lua">
 +
--original bitmap
 
local source = Bitmap.new(Texture.new("crate.png", true))
 
local source = Bitmap.new(Texture.new("crate.png", true))
  
Line 27: Line 33:
 
frame = frame + 1
 
frame = frame + 1
 
rt:draw(source)
 
rt:draw(source)
end)</source>
+
end)
 +
</syntaxhighlight>
 +
 
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Methods</translate> ===
+
=== Methods ===
[[Special:MyLanguage/RenderTarget.new|RenderTarget.new]] ''<translate>Creates new RenderTarget object</translate>''<br/>
+
[[RenderTarget.new]] ''creates a new RenderTarget object''<br/><!--GIDEROSMTD:RenderTarget.new(width,height,filtering,repeat,autoscale) creates a new RenderTarget object-->
[[Special:MyLanguage/RenderTarget:clear|RenderTarget:clear]] ''<translate>Clears rendered texture</translate>''<br/>
+
[[RenderTarget:clear]] ''clears rendered texture''<br/><!--GIDEROSMTD:RenderTarget:clear(color,alpha,x,y,width,height) clears rendered texture-->
[[Special:MyLanguage/RenderTarget:draw|RenderTarget:draw]] ''<translate>Renders provided object</translate>''<br/>
+
[[RenderTarget:draw]] ''renders provided object''<br/><!--GIDEROSMTD:RenderTarget:draw(sprite,x,y) renders provided object-->
[[Special:MyLanguage/RenderTarget:getPixel|RenderTarget:getPixel]] ''<translate>Returns single pixels color and alpha channel</translate>''<br/>
+
[[RenderTarget:generateMipmap]] ''recomputes mipmaps''<br/><!--GIDEROSMTD:RenderTarget:generateMipmap() recomputes mipmaps-->
[[Special:MyLanguage/RenderTarget:getPixels|RenderTarget:getPixels]] ''<translate>Returns buffer containing color and alpha data from provided rectangle</translate>''<br/>
+
[[RenderTarget:getPixel]] ''returns single pixels color and alpha channel''<br/><!--GIDEROSMTD:RenderTarget:getPixel(x,y) returns single pixels color and alpha channel-->
[[Special:MyLanguage/RenderTarget:save|RenderTarget:save]] ''<translate>save contents of RenderTarget as image</translate>''<br/>
+
[[RenderTarget:getPixels]] ''returns buffer containing color and alpha data from provided rectangle''<br/><!--GIDEROSMTD:RenderTarget:getPixels(x,y,w,h) returns buffer containing color and alpha data from provided rectangle-->
 +
[[RenderTarget:save]] ''saves content of RenderTarget as image''<br/><!--GIDEROSMTD:RenderTarget:save(filename,x,y,width,height) saves content of RenderTarget as image-->
 +
 
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Events</translate> ===
+
=== Events ===
=== <translate>Constants</translate> ===
+
=== Constants ===
 
|}
 
|}
 +
 +
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 12:56, 30 April 2024

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2013.06
Inherits from: TextureBase

Description

RenderTarget is a texture on which provided Sprite hierarchy can be rendered.

It can be used in any case in which Texture can be used.

Example

Using a texture and updating RenderTarget

--original bitmap
local source = Bitmap.new(Texture.new("crate.png", true))

--render target
local rt = RenderTarget.new(source:getWidth(), source:getHeight())

--bitmap with rendertarget as texture
local bmp = Bitmap.new(rt)
bmp:setPosition(200, 0)
stage:addChild(bmp)

--updating source updated Bitmap
local frame = 0
stage:addEventListener(Event.ENTER_FRAME, function(event)
	local r = math.sin(frame * 0.03) * 0.3 + 0.7
	local g = math.sin(frame * 0.04) * 0.3 + 0.7
	local b = math.sin(frame * 0.05) * 0.3 + 0.7
	source:setColorTransform(r, g, b, 1)
	frame = frame + 1
	rt:draw(source)
end)

Methods

RenderTarget.new creates a new RenderTarget object
RenderTarget:clear clears rendered texture
RenderTarget:draw renders provided object
RenderTarget:generateMipmap recomputes mipmaps
RenderTarget:getPixel returns single pixels color and alpha channel
RenderTarget:getPixels returns buffer containing color and alpha data from provided rectangle
RenderTarget:save saves content of RenderTarget as image

Events

Constants