livewp/example.lua

38 lines
1.3 KiB
Lua
Raw Normal View History

2024-04-09 12:13:23 +03:00
2024-04-09 17:45:27 +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
function tick()
-- Background
2024-04-09 17:45:27 +03:00
Screen.clear(0xFF131313)
2024-04-09 12:13:23 +03:00
-- Color ARGB, x, y
2024-04-09 17:45:27 +03:00
Draw.pixel(0xFFFF0000, 30, 30)
2024-04-09 12:13:23 +03:00
-- Color ARGB, thickness, x1, y1, x2, y2, xn, yn, ...
2024-04-09 17:45:27 +03:00
Draw.line(0xFFFF00FF, 8, 100, 100, 200, 400, 300, 600) --> { Vec2, ... }
2024-04-09 12:13:23 +03:00
-- Color ARGB, thickness, x1, y1, x2, y2, xn, yn, ...
2024-04-09 17:45:27 +03:00
Draw.poly(0xFFFF00FF, 8, 100, 100, 200, 400, 300, 600) --> Rect
2024-04-09 12:13:23 +03:00
-- Color ARGB, radius, x, y, start, end
2024-04-09 17:45:27 +03:00
Draw.circle(0xFFFF0000, 20, 300, 300) --> Rect
2024-04-09 12:13:23 +03:00
-- Color ARGB, outer, inner, x, y, start, end
2024-04-09 17:45:27 +03:00
Draw.ring(0xFF00FF00, 30, 20, 300, 300) --> Rect
2024-04-09 12:13:23 +03:00
-- Color ARGB, x, y, w, h
2024-04-09 17:45:27 +03:00
Draw.rect_fill(0xFF00FFFF, 100, 700, 320, 240) --> Rect
2024-04-09 12:13:23 +03:00
-- Color ARGB, thickness, x, y, w, h
2024-04-09 17:45:27 +03:00
Draw.rect(0xFFFF00FF, 8, 100, 700, 320, 240) --> Rect
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 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