Copyable Example Code
You can paste this into the code editor; still verify target image, region, color, text, and timing values in your own device flow.
-- Dialog: radio group
local cfg = Setting.builder()
cfg:setTitle("Mode")
cfg:add("speed", RadioGroup({ "Slow", "Normal", "Fast", "Very fast" }, 1))
cfg:add("area", RadioGroup({ "Full screen", "Top half", "Bottom half", "Center" }, 0))
local result = cfg:build():show()
if type(result) ~= "table" then return end
-- Selection controls return the selected option text.
local speed = result["speed"] or "Normal"
local area = result["area"] or "Full screen"
-- Pick a delay for the speed
local delays = { Slow = 1000, Normal = 500, Fast = 200, ["Very fast"] = 50 }
local delay = delays[speed] or 500
-- Pick a Region for the area
local screen = Region()
local sw = screen:getW()
local sh = screen:getH()
local areas = {
["Full screen"] = { 0, 0, sw, sh },
["Top half"] = { 0, 0, sw, math.floor(sh / 2) },
["Bottom half"] = { 0, math.floor(sh / 2), sw, sh - math.floor(sh / 2) },
["Center"] = { math.floor(sw * 0.18), math.floor(sh * 0.20), math.floor(sw * 0.64), math.floor(sh * 0.58) },
}
local b = areas[area] or areas["Full screen"]
local region = Region(b[1], b[2], b[3], b[4])
toast("Mode: " .. speed .. ", delay: " .. delay .. " ms")