API FadeControl
FadeControl
Definition:
FadeControl(userdata control, int timetofade, float startalpha, endalpha, function cb, ...) -> nil
Description:
Fade an iup control by modifying its alpha field. Usually a label.
Arguments:
control iup control to fade
timetofade time to fade in seconds
startalpha alpha value before fading (0-1)
endalpha alpha value after fading(0-1)
cb function to call when done
... arguments to pass to cb
Example:
<source lang="lua">
-- shows a dialog with a label that will fade away on clicking "Fade"
-- clicking on "Stop" interrupts the process
local d, label, fadebutton, stopbutton
label = iup.label{title="Fade me!"}
local function fadebutton_cb()
local function fade_cb()
label.alpha = "255" -- reset the alpha when done
end
FadeControl(label, 5, 1, 0, fade_cb) -- fade for 5 seconds from full to zero alpha
end
local function stopbutton_cb()
local fadeinfo = FadeLookup(label) -- get the fade info table for the label
if fadeinfo then -- check if the control is still being faded
print("Fading was stopped after "..tostring(fadeinfo.counter).." seconds") -- print elapsed time
end
FadeStop(label) -- interrupt fading
label.alpha = "255" -- reset alpha
end
fadebutton = iup.button{title="Fade", action=fadebutton_cb}
stopbutton = iup.button{title="Stop", action=stopbutton_cb}
d = iup.dialog{iup.vbox{label, fadebutton, stopbutton}}
d:show()
</source>