livewp/example.lua

38 lines
1.3 KiB
Lua
Raw Normal View History

2024-04-09 12:13:23 +03:00
local img = assert(image_load("/home/hkc/images/wallpapers/wallpaper.png"))
local font = assert(font_load("/usr/share/fonts/TTF/TerminusTTF.ttf"))
function tick()
-- Background
clear_screen(0xFF131313)
-- Color ARGB, x, y
draw_pixel(0xFFFF0000, 30, 30)
-- Color ARGB, thickness, x1, y1, x2, y2, xn, yn, ...
draw_line(0xFFFF00FF, 8, 100, 100, 200, 400, 300, 600) --> { Vec2, ... }
-- Color ARGB, thickness, x1, y1, x2, y2, xn, yn, ...
draw_poly(0xFFFF00FF, 8, 100, 100, 200, 400, 300, 600) --> Rect
-- Color ARGB, radius, x, y, start, end
draw_circle(0xFFFF0000, 20, 300, 300) --> Rect
-- Color ARGB, outer, inner, x, y, start, end
draw_ring(0xFF00FF00, 30, 20, 300, 300) --> Rect
-- Color ARGB, x, y, w, h
draw_rect_fill(0xFF00FFFF, 100, 700, 320, 240) --> Rect
-- Color ARGB, thickness, x, y, w, h
draw_rect(0xFFFF00FF, 8, 100, 700, 320, 240) --> 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