Picture:resize(factor) method
Resize the Picture by a certain amount.
Parameters
factor
A number indicating the scale factor to apply. Using a value inferior to 1 will shrink the Picture. A value superior to 1 will enlarge the Picture.
Return value
This function returns no value.Example
local ui = require "ui"
-- create a Window
local win = ui.Window("Picture:resize() sample", 512, 380)
-- create an empty Picture
local img = ui.Picture(win, "")
-- create a button
local button = ui.Button(win, "Replay")
-- variable will hold the scale factor
local factor = 0
function button:onClick()
self:hide()
factor = 0
end
function win:onResize()
img:center()
button:center()
button.y = img.y+img.height+20
end
-- load image
img:load("LuaRT.png")
win:center()
button:hide()
win:show()
repeat
ui.update()
-- stop resizing when factor is inferior to 1
if factor < 1 then
factor = factor + 0.05
-- resize the Picture
img:resize(factor)
img:center()
if factor >= 1 then
win:onResize()
button:show()
end
end
until win.visible == false