RadialGradient.center read/write property
Get or set the center coordinates of the gradient ellipse
To set this property, use a table as a list of two numbers, for example { 0, 0 }
When getting this property, you can access the coordinates by using the fields x
and y
Example
local ui = require "ui"
require "canvas"
-- create a simple Window
local win = ui.Window("RadialGradient.center sample", "fixed", 500, 400)
-- create a Canvas
local canvas = ui.Canvas(win)
canvas.align = "all"
local gradient = canvas:RadialGradient { [0] = 0x00FFFFFF, [1] = 0x00008bFF }
gradient.center = { canvas.width/2, canvas.height/2 }
gradient.radius = { canvas.width/2, canvas.height/2 }
function canvas:onPaint()
self:fillrect(0, 0, canvas.width, canvas.height, gradient)
end
function canvas:onHover(x,y buttons)
gradient.center = { x, y }
end
win:show()
-- update user interface
repeat
ui.update()
until not win.visible