diff --git a/.gitignore b/.gitignore index 8b2f6ca..0c9690c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ obj/* livewp -mess/cairo-xcb +mess/* +!mess/*.* diff --git a/example.lua b/example.lua index a42eff3..2313e55 100644 --- a/example.lua +++ b/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 diff --git a/mess/lua-api.c b/mess/lua-api.c new file mode 100644 index 0000000..3d23a5d --- /dev/null +++ b/mess/lua-api.c @@ -0,0 +1,25 @@ +// x-run: ~/scripts/runc.sh % -lm -llua + + +#include +#include +#include +#include + +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; +} diff --git a/mess/lua-api.lua b/mess/lua-api.lua new file mode 100644 index 0000000..e312912 --- /dev/null +++ b/mess/lua-api.lua @@ -0,0 +1,2 @@ + +meow()