love.graphics.setStencil

Defines or releases a mask for the drawing operations.

The passed function draws to the mask instead of the screen, creating an image with transparent and opaque pixel. While active, it is used to test where pixel will be drawn or discarded.
Calling the function without arguments releases the active mask.

Function

Synopsis

love.graphics.setMask( maskFunction )

Arguments

function maskFunction
Function that draws to the mask.

Returns

Nothing.

Function

Synopsis

love.graphics.setMask( )

Arguments

None.

Returns

Nothing.

Notes

Releases the active mask.

Examples

Drawing a circle with a hole

myMask = function()
   love.graphics.circle("fill", 400, 300, 50)
end

love.graphics.setMask(myMask)
love.graphics.circle("fill", 400, 300, 150)

Drawing two masked triangles with different colors

myMask = function()
   love.graphics.circle("fill", 400, 300, 60, 25)
end

love.graphics.setMask(myMask)
love.graphics.setColor(155, 0, 128)
love.graphics.triangle("fill", 400, 200, 486, 350, 314, 350)


love.graphics.setInvertedMask(myMask)
love.graphics.setColor(144, 214, 128)
love.graphics.triangle("fill", 400, 200, 486, 350, 314, 350)

See Also


Other Languages