neyuki 0.6.2

A small Lua-like scripting language implemented in Rust
-- Shows an image file (PNG, JPEG, WebP, GIF or BMP) as a rounded, cover-fitted
-- card. Animated GIF and WebP files play at their own speed. Pass the path as
-- the first argument; Escape or the close button ends it.

local ui = require("@neyuki/ui")
local os = require("@neyuki/os")

local path = os.args()[1] ?? "tests/fixtures/spin.gif"
local img = ui.loadImage(path)
print(path .. ": " .. img.width .. "x" .. img.height .. ", " .. img.frames .. " frame(s)")

local win = ui.open({ title = "Neyuki image", width = 480, height = 320 })
local anim = ui.animation(img)

ui.run(function(events: {Event}, dt: number)
    for _, event in events do
        if (event.kind == "keydown" and event.key == "escape") then
            win:close()
            return
        end
    end

    anim:update(dt)
    local w, h = win:size()
    win:clear("#1e1e2e")
    win:drawImage(img, 20, 20, {
        width = w - 40,
        height = h - 40,
        fit = "cover",
        radius = 16,
        frame = anim.frame,
    })
    win:present()
end)

img:close()