livewp/example.lua

42 lines
1.5 KiB
Lua
Raw Normal View History

2024-04-09 12:13:23 +03:00
2024-04-09 18:33:54 +03:00
-- local img = assert(Image.load("/home/hkc/images/wallpapers/wallpaper.png"))
-- local font = assert(Font.load("/usr/share/fonts/TTF/TerminusTTF.ttf"))
2024-04-09 12:13:23 +03:00
2024-04-09 18:33:54 +03:00
function tick(t)
2024-04-09 12:13:23 +03:00
-- Background
2024-04-09 19:53:35 +03:00
Draw.clear(0xFF131300 | math.floor(128 + math.sin(t) * 127))
2024-04-09 12:13:23 +03:00
-- Color ARGB, x, y
2024-04-09 19:53:35 +03:00
Draw.pixel(0xFFFF0000,
(math.sin(t) * 0.5 + 0.5) * 1920,
(math.cos(t) * 0.5 + 0.5) * 1080)
2024-04-09 12:13:23 +03:00
2024-04-09 19:53:35 +03:00
-- Color ARGB, x1, y1, x2, y2, xn, yn, ...
2024-04-09 20:45:35 +03:00
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
2024-04-09 20:45:35 +03:00
-- Color ARGB, x, y, w, h
Draw.rect_fill(0xFF00FFFF, 100, 700, 320, 240) --> Rect
2024-04-09 12:13:23 +03:00
-- Color ARGB, radius, x, y, start, end
Draw.circle(0xFFFF0000, 40, 300, 300, t, t + math.pi / 2) --> Rect
2024-04-09 12:13:23 +03:00
-- Color ARGB, outer, inner, x, y, start, end
Draw.ring(0xFFFFFFFF, 30, 20, 300, 300, t, t + math.pi) --> Rect
2024-04-09 12:13:23 +03:00
--[[
2024-04-09 12:13:23 +03:00
-- font, text, size, x, y, Color ARGB
2024-04-09 17:45:27 +03:00
Draw.text(font, "Hello, world!", 32, 400, 400, 0xFFFF00FF) --> Rect
2024-04-09 12:13:23 +03:00
-- image ptr x, y, w, h, src_x, src_y, src_w, src_h
2024-04-09 17:45:27 +03:00
Draw.image( img, 0, 0) --> Rect
2024-04-09 18:33:54 +03:00
]]
2024-04-09 12:13:23 +03:00
end
function unload()
2024-04-09 17:45:27 +03:00
Image.free(img)
Font.free(font)
2024-04-09 12:13:23 +03:00
end