Difference between revisions of "RenderTarget"
From GiderosMobile
Line 5: | Line 5: | ||
'''<translate>Available since</translate>:''' Gideros 2013.06<br/> | '''<translate>Available since</translate>:''' Gideros 2013.06<br/> | ||
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/TextureBase|TextureBase]]<br/> | '''<translate>Inherits from</translate>:''' [[Special:MyLanguage/TextureBase|TextureBase]]<br/> | ||
+ | |||
=== <translate>Description</translate> === | === <translate>Description</translate> === | ||
<translate>RenderTarget is a texture on which provided Sprite hierarchy can be rendered. | <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> | It can be used in any case in which Texture can be used.</translate> | ||
+ | |||
=== <translate>Examples</translate> === | === <translate>Examples</translate> === | ||
− | '''Using as texture and updating RenderTarget''' | + | '''Using as texture and updating RenderTarget:''' |
− | <source lang="lua">--original bitmap | + | <source lang="lua"> |
+ | --original bitmap | ||
local source = Bitmap.new(Texture.new("crate.png", true)) | local source = Bitmap.new(Texture.new("crate.png", true)) | ||
Line 30: | Line 33: | ||
frame = frame + 1 | frame = frame + 1 | ||
rt:draw(source) | rt:draw(source) | ||
− | end)</source> | + | end) |
+ | </source> | ||
+ | |||
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
Line 40: | Line 45: | ||
[[Special:MyLanguage/RenderTarget:getPixels|RenderTarget:getPixels]] ''<translate>Returns buffer containing color and alpha data from provided rectangle</translate>''<br/><!-- GIDEROSMTD:RenderTarget:getPixels(x,y,w,h) Returns buffer containing color and alpha data from provided rectangle --> | [[Special:MyLanguage/RenderTarget:getPixels|RenderTarget:getPixels]] ''<translate>Returns buffer containing color and alpha data from provided rectangle</translate>''<br/><!-- GIDEROSMTD:RenderTarget:getPixels(x,y,w,h) Returns buffer containing color and alpha data from provided rectangle --> | ||
[[Special:MyLanguage/RenderTarget:save|RenderTarget:save]] ''<translate>save contents of RenderTarget as image</translate>''<br/><!-- GIDEROSMTD:RenderTarget:save(filename,x,y,width,height) save contents of RenderTarget as image --> | [[Special:MyLanguage/RenderTarget:save|RenderTarget:save]] ''<translate>save contents of RenderTarget as image</translate>''<br/><!-- GIDEROSMTD:RenderTarget:save(filename,x,y,width,height) save contents of RenderTarget as image --> | ||
+ | |||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
=== <translate>Events</translate> === | === <translate>Events</translate> === | ||
=== <translate>Constants</translate> === | === <translate>Constants</translate> === | ||
|} | |} | ||
− | |||
− |
Revision as of 23:57, 9 December 2019
Supported platforms:
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.
Examples
Using as 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)
MethodsRenderTarget.new Creates new RenderTarget object |
EventsConstants |