livewp/example.lua

42 lines
1.5 KiB
Lua

-- local img = assert(Image.load("/home/hkc/images/wallpapers/wallpaper.png"))
-- local font = assert(Font.load("/usr/share/fonts/TTF/TerminusTTF.ttf"))
function tick(t)
-- Background
Draw.clear(0xFF131300 | math.floor(128 + math.sin(t) * 127))
-- Color ARGB, x, y
Draw.pixel(0xFFFF0000,
(math.sin(t) * 0.5 + 0.5) * 1920,
(math.cos(t) * 0.5 + 0.5) * 1080)
-- Color ARGB, x1, y1, x2, y2, xn, yn, ...
Draw.poly(0xFF00FFFF, 100, 100, 200, 100, 300, 600) --> Rect
-- Color ARGB, thickness, x1, y1, x2, y2, xn, yn, ...
Draw.line(0xFFFF00FF, 8, 100, 100, 200, 100, 300, 600, 100, 100) --> { Vec2, ... }
-- Color ARGB, thickness, x, y, w, h
Draw.rect(0xFFFF000F, 4, 100, 700, 320, 240) --> Rect
-- Color ARGB, x, y, w, h
Draw.rect_fill(0xFF00FFFF, 100, 700, 320, 240) --> Rect
-- Color ARGB, radius, x, y, start, end
Draw.circle(0xFFFF0000, 40, 300, 300, t, t + math.pi / 2) --> Rect
-- Color ARGB, outer, inner, x, y, start, end
Draw.ring(0xFFFFFFFF, 30, 20, 300, 300, t, t + math.pi) --> Rect
--[[
-- font, text, size, x, y, Color ARGB
Draw.text(font, "Hello, world!", 32, 400, 400, 0xFFFF00FF) --> Rect
-- image ptr x, y, w, h, src_x, src_y, src_w, src_h
Draw.image( img, 0, 0) --> Rect
]]
end
function unload()
Image.free(img)
Font.free(font)
end