CANVAS:set alpha

CANVAS:set_alpha(value)

Set the transparency level with which subsequent draw operations should be performed. The default value for alpha is 255 (fully opaque).

Parameters:

value

An integer value from 0 (transparent) to 255 (opaque). Values outside this range will be clamped.

Example:

-- Draw three colored bars with different opacities across the canvas on
-- an orange background
function FillRGB(name)
    local canvas = gre.get_canvas(name)
    local size = canvas:get_dimensions()
    local rw = size.width / 3
    canvas:fill(0xff8000)
    canvas:set_alpha(50)
    canvas:fill_rect(0,    0, rw,   size.height, 0xff0000)
    canvas:set_alpha(150)
    canvas:fill_rect(rw,   0, 2*rw, size.height, 0x00ff00)
    canvas:set_alpha(255)
    canvas:fill_rect(2*rw, 0, 3*rw, size.height, 0x0000ff)
end
Was this article helpful?
0 out of 0 found this helpful