Some API changes and playing w/ liblua
This commit is contained in:
parent
20cc7fcfc7
commit
6e9ea2dfbf
|
@ -1,3 +1,4 @@
|
|||
obj/*
|
||||
livewp
|
||||
mess/cairo-xcb
|
||||
mess/*
|
||||
!mess/*.*
|
||||
|
|
28
example.lua
28
example.lua
|
@ -1,37 +1,37 @@
|
|||
|
||||
local img = assert(image_load("/home/hkc/images/wallpapers/wallpaper.png"))
|
||||
local font = assert(font_load("/usr/share/fonts/TTF/TerminusTTF.ttf"))
|
||||
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)
|
||||
Screen.clear(0xFF131313)
|
||||
|
||||
-- Color ARGB, x, y
|
||||
draw_pixel(0xFFFF0000, 30, 30)
|
||||
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, ... }
|
||||
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
|
||||
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
|
||||
Draw.circle(0xFFFF0000, 20, 300, 300) --> Rect
|
||||
-- Color ARGB, outer, inner, x, y, start, end
|
||||
draw_ring(0xFF00FF00, 30, 20, 300, 300) --> Rect
|
||||
Draw.ring(0xFF00FF00, 30, 20, 300, 300) --> Rect
|
||||
|
||||
-- Color ARGB, x, y, w, h
|
||||
draw_rect_fill(0xFF00FFFF, 100, 700, 320, 240) --> Rect
|
||||
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
|
||||
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
|
||||
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
|
||||
Draw.image( img, 0, 0) --> Rect
|
||||
end
|
||||
|
||||
function unload()
|
||||
image_free(img)
|
||||
font_free(font)
|
||||
Image.free(img)
|
||||
Font.free(font)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
// x-run: ~/scripts/runc.sh % -lm -llua
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <lua5.2/lua.h>
|
||||
#include <lua5.2/lualib.h>
|
||||
#include <lua5.2/lauxlib.h>
|
||||
|
||||
int meow(lua_State *state) {
|
||||
printf("meow!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
lua_State *lua = luaL_newstate();
|
||||
luaL_openlibs(lua);
|
||||
|
||||
lua_pushcfunction(lua, meow);
|
||||
lua_setglobal(lua, "meow");
|
||||
|
||||
luaL_dofile(lua, "./lua-api.lua");
|
||||
|
||||
lua_close(lua);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
meow()
|
Loading…
Reference in New Issue