texture:draw()

Type Function
Object TextureResourceCanvas
Library graphics.*
Revision Release 2022.3683
See also TextureResource
TextureResourceCanvas
texture:invalidate()

Overview

This method adds/renders a display object to the internal rendering queue of the TextureResourceCanvas object. All rendering of queued objects occurs after calling texture:invalidate().

Gotchas

Inserting a display object into the rendering queue also removes the object from its current group or the stage, since objects cannot exist in multiple groups.

Syntax

texture:draw( object )
object (required)

DisplayObject. The object to be inserted into the rendering queue.

Example

local tex = graphics.newTexture( { type="canvas", width=128, height=128 } )

-- Create a circle and draw/render it to the texture
local circ = display.newCircle( 0, 0, 64 )
circ:setFillColor( { type="gradient", color1={0,0.2,1}, color2={0.8,0.8,0.8}, direction="down" } )
tex:draw( circ )

-- Schedule texture objects to be rendered to texture before next frame
tex:invalidate()