LinearGradient.opacity read/write property
Get or set the degree of opacity of the linear gradient, a number
starting from 0.0
(full transparency) to 1.0
(full opacity)
Example
local ui = require "ui"
require "canvas"
-- create a simple Window
local win = ui.Window("LinearGradient.opacity sample", "fixed", 500, 400)
-- create a Canvas
local canvas = ui.Canvas(win)
canvas.align = "all"
local gradient = canvas:LinearGradient { [0] = 0xE30940FF, [0.33] = 0xE7D702FF, [0.66] = 0x0FA895FF, [1] = 0x1373E8FF }
gradient.start = { 0, 0 }
gradient.stop = { canvas.width, 0 }
gradient.opacity = 0.5
function canvas:onPaint()
self.begin()
self:clear()
self:fillrect(0, 0, canvas.width, canvas.height, gradient)
self:flip()
end
ui.run(win):wait()