texture:setBackground()

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

Overview

Sets the fill color of the texture, also known as the "clear color" or the background. The entire texture will be set to the specified color during the next scheduled non-accumulative rendering. Default is transparent.

Syntax

texture:setBackground( gray )
texture:setBackground( gray, alpha )
texture:setBackground( red, green, blue )
texture:setBackground( red, green, blue, alpha )
gray, red, green, blue, alpha (optional)

Numbers. Numbers between 0 and 1 that represent the corresponding value for that channel. alpha represents the opacity of the texture without anything rendered to it.

Example

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

-- Set texture background to magenta
tex:setBackground( 1, 0, 1 )
tex:invalidate()