Type String Object Paint Library display.* Revision Release 2024.3703 Keywords additive blends, blend mode, blending, Porter-Duff See also Paint object.fill object.blendMode
Allows you to change the blend mode on a specific object.
Standard blend modes can be specified via one of the following strings:
"normal"
— This is the standard blend mode."add"
— Also known as linear dodge. Additive blends are useful for glowing effects."multiply"
— Multiply blends are useful for creating shadows. Blending with white results in no change; blending with other colors will darken the composited image."screen"
— This is useful for lightening images without lightening the darkest areas.Porter-Duff blend modes can be specified via one of the strings listed below.
"clear"
"src"
"dst"
"srcOver"
"dstOver"
"srcIn"
"dstIn"
"srcOut"
"dstOut"
"srcAtop"
"dstAtop"
"xor"
Custom blend modes allow you to control how the source and destination factors are used in the blending calculation. They follow the blend factors discussed in the OpenGL-ES 2 specification.
You can specify custom blend modes via a Lua table that specifies the source and destination factors as
String. By default, same as srcColor
.
"zero"
"one"
"srcColor"
"oneMinusSrcColor"
"dstColor"
"oneMinusDstColor"
"srcAlpha"
"oneMinusSrcAlpha"
"dstAlpha"
"oneMinusDstAlpha"
"srcAlphaSaturate"
Some Android devices do not consistently load images as premultiplied alpha. We have applied workarounds but they are not foolproof. On those devices, the "multiply"
and "screen"
blend modes will not work correctly, and you should see a single warning message in the console about it.
Porter-Duff blend modes will only work with images that have been loaded as premultiplied alpha.
local laser = display.newImage( "blendmode_laser.png" ) laser.fill.blendMode = "add"
local laser = display.newImage( "blendmode_laser.png" ) laser.fill.blendMode = "srcAtop"
local laser = display.newImage( "blendmode_laser.png" ) local customBlend = { srcColor = "srcColor", srcAlpha = "oneMinusDstColor", dstColor = "dstAlpha", dstAlpha = "srcAlphaSaturate" } laser.fill.blendMode = customBlend