From f702715aa3173abb82c10b479b5d61c28a87f5d1 Mon Sep 17 00:00:00 2001 From: arne Date: Sun, 5 Oct 2025 09:45:14 +0200 Subject: [PATCH] Be a good c-tizen and split `paper.h` into header and implementation --- main/CMakeLists.txt | 8 +- main/paper.c | 309 +++++++++++++++++++++++++++++++++++++++++++ main/paper.h | 313 +------------------------------------------- 3 files changed, 319 insertions(+), 311 deletions(-) create mode 100644 main/paper.c diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 170c783..deae97f 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,2 +1,6 @@ -idf_component_register(SRCS "inkpot.c" - INCLUDE_DIRS ".") +idf_component_register( + SRCS + "inkpot.c" + "paper.c" + INCLUDE_DIRS "." +) diff --git a/main/paper.c b/main/paper.c new file mode 100644 index 0000000..e2c6c3f --- /dev/null +++ b/main/paper.c @@ -0,0 +1,309 @@ +#include "paper.h" + +// this file defines lua bindings to the epdiy e-ink library. +// +// see https://epdiy.readthedocs.io/en/latest/api.html for epdiy documentation. +// see https://www.lua.org/manual/5.4/manual.html for lua documentation. + +EpdiyHighlevelState hl; +uint8_t* fb; + +static int init (lua_State *L) { + epd_init(&epd_board_lilygo_t5_47, &ED047TC1, EPD_LUT_64K); + // epd_set_vcom(1560); + hl = epd_hl_init(WAVEFORM); + epd_set_rotation(EPD_ROT_LANDSCAPE); + fb = epd_hl_get_framebuffer(&hl); + return 0; +} + +static int clear (lua_State *L){ + epd_clear(); + return 0; +} + +static int get_width (lua_State *L) { + int width = epd_rotated_display_width(); + lua_pushnumber(L, width); + return 1; +} + +static int get_height (lua_State *L) { + int height = epd_rotated_display_height(); + lua_pushnumber(L, height); + return 1; +} + +static int set_rotation (lua_State *L) { + char *rotation = lua_tostring(L, -1); + luaL_argcheck( + L, + strcmp(rotation, "landscape") == 0 || + strcmp(rotation, "portrait") == 0 || + strcmp(rotation, "inverted_landscape") == 0 || + strcmp(rotation, "inverted_portrait") == 0, + 1, + "expected `rotation` to be either 'landscape', 'portrait', 'inverted_landscape' or 'inverted_portrait'" + ); + epd_set_rotation( + strcmp(rotation, "landscape") == 0 + ? EPD_ROT_LANDSCAPE + : strcmp(rotation, "portrait") == 0 + ? EPD_ROT_PORTRAIT + : strcmp(rotation, "inverted_landscape") == 0 + ? EPD_ROT_INVERTED_LANDSCAPE + : EPD_ROT_INVERTED_PORTRAIT + ); + return 0; +} + +static int get_rotation (lua_State *L) { + int rotation = epd_get_rotation(); + lua_pushstring( + L, + rotation == EPD_ROT_LANDSCAPE + ? "landscape" + : rotation == EPD_ROT_PORTRAIT + ? "portrait" + : rotation == EPD_ROT_INVERTED_LANDSCAPE + ? "inverted_landscape" + : "inverted_portrait" + ); + return 1; +} + +static int draw_pixel (lua_State *L) { + int x, y, color; + int isnum; + + x = lua_tonumberx(L, 1, &isnum); + luaL_argcheck(L, isnum, 1, "expected `x` to be a number"); + y = lua_tonumberx(L, 2, &isnum); + luaL_argcheck(L, isnum, 2, "expected `y` to be a number"); + color = lua_tonumberx(L, 3, &isnum); + luaL_argcheck(L, isnum && color >= 0 && color < 256, 3, "expected `color` to be a number within [0, 255]"); + + epd_draw_pixel(x, y, color, fb); + return 0; +} + +static int draw_line (lua_State *L) { + int x1, y1, x2, y2, color; + int isnum; + + x1 = lua_tonumberx(L, 1, &isnum); + luaL_argcheck(L, isnum, 1, "expected `x1` to be a number"); + y1 = lua_tonumberx(L, 2, &isnum); + luaL_argcheck(L, isnum, 2, "expected `y1` to be a number"); + x2 = lua_tonumberx(L, 3, &isnum); + luaL_argcheck(L, isnum, 3, "expected `x2` to be a number"); + y2 = lua_tonumberx(L, 4, &isnum); + luaL_argcheck(L, isnum, 4, "expected `y2` to be a number"); + color = lua_tonumberx(L, 5, &isnum); + luaL_argcheck(L, isnum && color >= 0 && color < 256, 5, "expected `color` to be a number within [0, 255]"); + + epd_draw_line(x1, y1, x2, y2, color, fb); + return 0; +} + +static int draw_hline (lua_State *L) { + int x, y, length, color; + int isnum; + + x = lua_tonumberx(L, 1, &isnum); + luaL_argcheck(L, isnum, 1, "expected `x` to be a number"); + y = lua_tonumberx(L, 2, &isnum); + luaL_argcheck(L, isnum, 2, "expected `y` to be a number"); + length = lua_tonumberx(L, 3, &isnum); + luaL_argcheck(L, isnum, 3, "expected `length` to be a number"); + color = lua_tonumberx(L, 4, &isnum); + luaL_argcheck(L, isnum && color >= 0 && color < 256, 4, "expected `color` to be a number within [0, 255]"); + + epd_draw_hline(x, y, length, color, fb); + return 0; +} + +static int draw_vline (lua_State *L) { + int x, y, length, color; + int isnum; + + x = lua_tonumberx(L, 1, &isnum); + luaL_argcheck(L, isnum, 1, "expected `x` to be a number"); + y = lua_tonumberx(L, 2, &isnum); + luaL_argcheck(L, isnum, 2, "expected `y` to be a number"); + length = lua_tonumberx(L, 3, &isnum); + luaL_argcheck(L, isnum, 3, "expected `length` to be a number"); + color = lua_tonumberx(L, 4, &isnum); + luaL_argcheck(L, isnum && color >= 0 && color < 256, 4, "expected `color` to be a number within [0, 255]"); + + epd_draw_vline(x, y, length, color, fb); + return 0; +} + +static int draw_circle (lua_State *L) { + int x, y, radius, color; + int isnum; + + x = lua_tonumberx(L, 1, &isnum); + luaL_argcheck(L, isnum, 1, "expected `x` to be a number"); + y = lua_tonumberx(L, 2, &isnum); + luaL_argcheck(L, isnum, 2, "expected `y` to be a number"); + radius = lua_tonumberx(L, 3, &isnum); + luaL_argcheck(L, isnum, 3, "expected `radius` to be a number"); + color = lua_tonumberx(L, 4, &isnum); + luaL_argcheck(L, isnum && color >= 0 && color < 256, 4, "expected `color` to be a number within [0, 255]"); + + epd_draw_circle(x, y, radius, color, fb); + return 0; +} + +static int fill_circle (lua_State *L) { + int x, y, radius, color; + int isnum; + + x = lua_tonumberx(L, 1, &isnum); + luaL_argcheck(L, isnum, 1, "expected `x` to be a number"); + y = lua_tonumberx(L, 2, &isnum); + luaL_argcheck(L, isnum, 2, "expected `y` to be a number"); + radius = lua_tonumberx(L, 3, &isnum); + luaL_argcheck(L, isnum, 3, "expected `radius` to be a number"); + color = lua_tonumberx(L, 4, &isnum); + luaL_argcheck(L, isnum && color >= 0 && color < 256, 4, "expected `color` to be a number within [0, 255]"); + + epd_fill_circle(x, y, radius, color, fb); + return 0; +} + +static int draw_rect (lua_State *L) { + int x1, y1, x2, y2, color; + int isnum; + + x1 = lua_tonumberx(L, 1, &isnum); + luaL_argcheck(L, isnum, 1, "expected `x1` to be a number"); + y1 = lua_tonumberx(L, 2, &isnum); + luaL_argcheck(L, isnum, 2, "expected `y1` to be a number"); + x2 = lua_tonumberx(L, 3, &isnum); + luaL_argcheck(L, isnum, 3, "expected `x2` to be a number"); + y2 = lua_tonumberx(L, 4, &isnum); + luaL_argcheck(L, isnum, 4, "expected `y2` to be a number"); + color = lua_tonumberx(L, 5, &isnum); + luaL_argcheck(L, isnum && color >= 0 && color < 256, 5, "expected `color` to be a number within [0, 255]"); + + EpdRect rect = { + .x = x1, + .y = y1, + .width = x2 - x1, + .height = y2 - y1 + }; + epd_draw_rect(rect, color, fb); + return 0; +} + +static int fill_rect (lua_State *L) { + int x1, y1, x2, y2, color; + int isnum; + + x1 = lua_tonumberx(L, 1, &isnum); + luaL_argcheck(L, isnum, 1, "expected `x1` to be a number"); + y1 = lua_tonumberx(L, 2, &isnum); + luaL_argcheck(L, isnum, 2, "expected `y1` to be a number"); + x2 = lua_tonumberx(L, 3, &isnum); + luaL_argcheck(L, isnum, 3, "expected `x2` to be a number"); + y2 = lua_tonumberx(L, 4, &isnum); + luaL_argcheck(L, isnum, 4, "expected `y2` to be a number"); + color = lua_tonumberx(L, 5, &isnum); + luaL_argcheck(L, isnum && color >= 0 && color < 256, 5, "expected `color` to be a number within [0, 255]"); + + EpdRect rect = { + .x = x1, + .y = y1, + .width = x2 - x1, + .height = y2 - y1 + }; + epd_fill_rect(rect, color, fb); + return 0; +} + +static int draw_triangle (lua_State *L) { + int x1, y1, x2, y2, x3, y3, color; + int isnum; + + x1 = lua_tonumberx(L, 1, &isnum); + luaL_argcheck(L, isnum, 1, "expected `x1` to be a number"); + y1 = lua_tonumberx(L, 2, &isnum); + luaL_argcheck(L, isnum, 2, "expected `y1` to be a number"); + x2 = lua_tonumberx(L, 3, &isnum); + luaL_argcheck(L, isnum, 3, "expected `x2` to be a number"); + y2 = lua_tonumberx(L, 4, &isnum); + luaL_argcheck(L, isnum, 4, "expected `y2` to be a number"); + x3 = lua_tonumberx(L, 5, &isnum); + luaL_argcheck(L, isnum, 5, "expected `x3` to be a number"); + y3 = lua_tonumberx(L, 6, &isnum); + luaL_argcheck(L, isnum, 6, "expected `y3` to be a number"); + color = lua_tonumberx(L, 7, &isnum); + luaL_argcheck(L, isnum && color >= 0 && color < 256, 7, "expected `color` to be a number within [0, 255]"); + + epd_draw_triangle(x1, y1, x2, y2, x3, y3, color, fb); + return 0; +} + +static int fill_triangle (lua_State *L) { + int x1, y1, x2, y2, x3, y3, color; + int isnum; + + x1 = lua_tonumberx(L, 1, &isnum); + luaL_argcheck(L, isnum, 1, "expected `x1` to be a number"); + y1 = lua_tonumberx(L, 2, &isnum); + luaL_argcheck(L, isnum, 2, "expected `y1` to be a number"); + x2 = lua_tonumberx(L, 3, &isnum); + luaL_argcheck(L, isnum, 3, "expected `x2` to be a number"); + y2 = lua_tonumberx(L, 4, &isnum); + luaL_argcheck(L, isnum, 4, "expected `y2` to be a number"); + x3 = lua_tonumberx(L, 5, &isnum); + luaL_argcheck(L, isnum, 5, "expected `x3` to be a number"); + y3 = lua_tonumberx(L, 6, &isnum); + luaL_argcheck(L, isnum, 6, "expected `y3` to be a number"); + color = lua_tonumberx(L, 7, &isnum); + luaL_argcheck(L, isnum && color >= 0 && color < 256, 7, "expected `color` to be a number within [0, 255]"); + + epd_fill_triangle(x1, y1, x2, y2, x3, y3, color, fb); + return 0; +} + +static int update (lua_State *L) { + int temperature = 25; + epd_poweron(); + epd_hl_update_screen(&hl, MODE_GC16, temperature); + epd_poweroff(); + return 0; +} + +static const struct luaL_Reg paper[] = { + {"init", init}, + {"clear", clear}, + + {"get_width", get_width}, + {"get_height", get_height}, + + {"set_rotation", set_rotation}, + {"get_rotation", get_rotation}, + + {"draw_pixel", draw_pixel}, + {"draw_line", draw_line}, + {"draw_hline", draw_hline}, + {"draw_vline", draw_vline}, + {"draw_circle", draw_circle}, + {"fill_circle", fill_circle}, + {"draw_rect", draw_rect}, + {"fill_rect", fill_rect}, + {"draw_triangle", draw_triangle}, + {"fill_triangle", fill_triangle}, + {"update", update}, + + {NULL, NULL}, +}; + +int luaopen_paper (lua_State *L) { + luaL_newlib(L, paper); + return 1; +} diff --git a/main/paper.h b/main/paper.h index b33d4fe..efd1503 100644 --- a/main/paper.h +++ b/main/paper.h @@ -1,321 +1,16 @@ #ifndef PAPER_H_ #define PAPER_H_ +#include #include #include #include -#include "departure_mono_11.h" -#include "departure_mono_22.h" +// #include "departure_mono_11.h" +// #include "departure_mono_22.h" #define WAVEFORM EPD_BUILTIN_WAVEFORM -// this file defines lua bindings to the epdiy e-ink library. -// -// see https://epdiy.readthedocs.io/en/latest/api.html for epdiy documentation. -// see https://www.lua.org/manual/5.4/manual.html for lua documentation. - -EpdiyHighlevelState hl; -uint8_t* fb; - -static int init (lua_State *L) { - epd_init(&epd_board_lilygo_t5_47, &ED047TC1, EPD_LUT_64K); - // epd_set_vcom(1560); - hl = epd_hl_init(WAVEFORM); - epd_set_rotation(EPD_ROT_LANDSCAPE); - fb = epd_hl_get_framebuffer(&hl); - return 0; -} - -static int clear (lua_State *L){ - epd_clear(); - return 0; -} - -static int get_width (lua_State *L) { - int width = epd_rotated_display_width(); - lua_pushnumber(L, width); - return 1; -} - -static int get_height (lua_State *L) { - int height = epd_rotated_display_height(); - lua_pushnumber(L, height); - return 1; -} - -static int set_rotation (lua_State *L) { - char *rotation = lua_tostring(L, -1); - luaL_argcheck( - L, - strcmp(rotation, "landscape") == 0 || - strcmp(rotation, "portrait") == 0 || - strcmp(rotation, "inverted_landscape") == 0 || - strcmp(rotation, "inverted_portrait") == 0, - 1, - "expected `rotation` to be either 'landscape', 'portrait', 'inverted_landscape' or 'inverted_portrait'" - ); - epd_set_rotation( - strcmp(rotation, "landscape") == 0 - ? EPD_ROT_LANDSCAPE - : strcmp(rotation, "portrait") == 0 - ? EPD_ROT_PORTRAIT - : strcmp(rotation, "inverted_landscape") == 0 - ? EPD_ROT_INVERTED_LANDSCAPE - : EPD_ROT_INVERTED_PORTRAIT - ); - return 0; -} - -static int get_rotation (lua_State *L) { - int rotation = epd_get_rotation(); - lua_pushstring( - L, - rotation == EPD_ROT_LANDSCAPE - ? "landscape" - : rotation == EPD_ROT_PORTRAIT - ? "portrait" - : rotation == EPD_ROT_INVERTED_LANDSCAPE - ? "inverted_landscape" - : "inverted_portrait" - ); - return 1; -} - -static int draw_pixel (lua_State *L) { - int x, y, color; - int isnum; - - x = lua_tonumberx(L, 1, &isnum); - luaL_argcheck(L, isnum, 1, "expected `x` to be a number"); - y = lua_tonumberx(L, 2, &isnum); - luaL_argcheck(L, isnum, 2, "expected `y` to be a number"); - color = lua_tonumberx(L, 3, &isnum); - luaL_argcheck(L, isnum && color >= 0 && color < 256, 3, "expected `color` to be a number within [0, 255]"); - - epd_draw_pixel(x, y, color, fb); - return 0; -} - -static int draw_line (lua_State *L) { - int x1, y1, x2, y2, color; - int isnum; - - x1 = lua_tonumberx(L, 1, &isnum); - luaL_argcheck(L, isnum, 1, "expected `x1` to be a number"); - y1 = lua_tonumberx(L, 2, &isnum); - luaL_argcheck(L, isnum, 2, "expected `y1` to be a number"); - x2 = lua_tonumberx(L, 3, &isnum); - luaL_argcheck(L, isnum, 3, "expected `x2` to be a number"); - y2 = lua_tonumberx(L, 4, &isnum); - luaL_argcheck(L, isnum, 4, "expected `y2` to be a number"); - color = lua_tonumberx(L, 5, &isnum); - luaL_argcheck(L, isnum && color >= 0 && color < 256, 5, "expected `color` to be a number within [0, 255]"); - - epd_draw_line(x1, y1, x2, y2, color, fb); - return 0; -} - -static int draw_hline (lua_State *L) { - int x, y, length, color; - int isnum; - - x = lua_tonumberx(L, 1, &isnum); - luaL_argcheck(L, isnum, 1, "expected `x` to be a number"); - y = lua_tonumberx(L, 2, &isnum); - luaL_argcheck(L, isnum, 2, "expected `y` to be a number"); - length = lua_tonumberx(L, 3, &isnum); - luaL_argcheck(L, isnum, 3, "expected `length` to be a number"); - color = lua_tonumberx(L, 4, &isnum); - luaL_argcheck(L, isnum && color >= 0 && color < 256, 4, "expected `color` to be a number within [0, 255]"); - - epd_draw_hline(x, y, length, color, fb); - return 0; -} - -static int draw_vline (lua_State *L) { - int x, y, length, color; - int isnum; - - x = lua_tonumberx(L, 1, &isnum); - luaL_argcheck(L, isnum, 1, "expected `x` to be a number"); - y = lua_tonumberx(L, 2, &isnum); - luaL_argcheck(L, isnum, 2, "expected `y` to be a number"); - length = lua_tonumberx(L, 3, &isnum); - luaL_argcheck(L, isnum, 3, "expected `length` to be a number"); - color = lua_tonumberx(L, 4, &isnum); - luaL_argcheck(L, isnum && color >= 0 && color < 256, 4, "expected `color` to be a number within [0, 255]"); - - epd_draw_vline(x, y, length, color, fb); - return 0; -} - -static int draw_circle (lua_State *L) { - int x, y, radius, color; - int isnum; - - x = lua_tonumberx(L, 1, &isnum); - luaL_argcheck(L, isnum, 1, "expected `x` to be a number"); - y = lua_tonumberx(L, 2, &isnum); - luaL_argcheck(L, isnum, 2, "expected `y` to be a number"); - radius = lua_tonumberx(L, 3, &isnum); - luaL_argcheck(L, isnum, 3, "expected `radius` to be a number"); - color = lua_tonumberx(L, 4, &isnum); - luaL_argcheck(L, isnum && color >= 0 && color < 256, 4, "expected `color` to be a number within [0, 255]"); - - epd_draw_circle(x, y, radius, color, fb); - return 0; -} - -static int fill_circle (lua_State *L) { - int x, y, radius, color; - int isnum; - - x = lua_tonumberx(L, 1, &isnum); - luaL_argcheck(L, isnum, 1, "expected `x` to be a number"); - y = lua_tonumberx(L, 2, &isnum); - luaL_argcheck(L, isnum, 2, "expected `y` to be a number"); - radius = lua_tonumberx(L, 3, &isnum); - luaL_argcheck(L, isnum, 3, "expected `radius` to be a number"); - color = lua_tonumberx(L, 4, &isnum); - luaL_argcheck(L, isnum && color >= 0 && color < 256, 4, "expected `color` to be a number within [0, 255]"); - - epd_fill_circle(x, y, radius, color, fb); - return 0; -} - -static int draw_rect (lua_State *L) { - int x1, y1, x2, y2, color; - int isnum; - - x1 = lua_tonumberx(L, 1, &isnum); - luaL_argcheck(L, isnum, 1, "expected `x1` to be a number"); - y1 = lua_tonumberx(L, 2, &isnum); - luaL_argcheck(L, isnum, 2, "expected `y1` to be a number"); - x2 = lua_tonumberx(L, 3, &isnum); - luaL_argcheck(L, isnum, 3, "expected `x2` to be a number"); - y2 = lua_tonumberx(L, 4, &isnum); - luaL_argcheck(L, isnum, 4, "expected `y2` to be a number"); - color = lua_tonumberx(L, 5, &isnum); - luaL_argcheck(L, isnum && color >= 0 && color < 256, 5, "expected `color` to be a number within [0, 255]"); - - EpdRect rect = { - .x = x1, - .y = y1, - .width = x2 - x1, - .height = y2 - y1 - }; - epd_draw_rect(rect, color, fb); - return 0; -} - -static int fill_rect (lua_State *L) { - int x1, y1, x2, y2, color; - int isnum; - - x1 = lua_tonumberx(L, 1, &isnum); - luaL_argcheck(L, isnum, 1, "expected `x1` to be a number"); - y1 = lua_tonumberx(L, 2, &isnum); - luaL_argcheck(L, isnum, 2, "expected `y1` to be a number"); - x2 = lua_tonumberx(L, 3, &isnum); - luaL_argcheck(L, isnum, 3, "expected `x2` to be a number"); - y2 = lua_tonumberx(L, 4, &isnum); - luaL_argcheck(L, isnum, 4, "expected `y2` to be a number"); - color = lua_tonumberx(L, 5, &isnum); - luaL_argcheck(L, isnum && color >= 0 && color < 256, 5, "expected `color` to be a number within [0, 255]"); - - EpdRect rect = { - .x = x1, - .y = y1, - .width = x2 - x1, - .height = y2 - y1 - }; - epd_fill_rect(rect, color, fb); - return 0; -} - -static int draw_triangle (lua_State *L) { - int x1, y1, x2, y2, x3, y3, color; - int isnum; - - x1 = lua_tonumberx(L, 1, &isnum); - luaL_argcheck(L, isnum, 1, "expected `x1` to be a number"); - y1 = lua_tonumberx(L, 2, &isnum); - luaL_argcheck(L, isnum, 2, "expected `y1` to be a number"); - x2 = lua_tonumberx(L, 3, &isnum); - luaL_argcheck(L, isnum, 3, "expected `x2` to be a number"); - y2 = lua_tonumberx(L, 4, &isnum); - luaL_argcheck(L, isnum, 4, "expected `y2` to be a number"); - x3 = lua_tonumberx(L, 5, &isnum); - luaL_argcheck(L, isnum, 5, "expected `x3` to be a number"); - y3 = lua_tonumberx(L, 6, &isnum); - luaL_argcheck(L, isnum, 6, "expected `y3` to be a number"); - color = lua_tonumberx(L, 7, &isnum); - luaL_argcheck(L, isnum && color >= 0 && color < 256, 7, "expected `color` to be a number within [0, 255]"); - - epd_draw_triangle(x1, y1, x2, y2, x3, y3, color, fb); - return 0; -} - -static int fill_triangle (lua_State *L) { - int x1, y1, x2, y2, x3, y3, color; - int isnum; - - x1 = lua_tonumberx(L, 1, &isnum); - luaL_argcheck(L, isnum, 1, "expected `x1` to be a number"); - y1 = lua_tonumberx(L, 2, &isnum); - luaL_argcheck(L, isnum, 2, "expected `y1` to be a number"); - x2 = lua_tonumberx(L, 3, &isnum); - luaL_argcheck(L, isnum, 3, "expected `x2` to be a number"); - y2 = lua_tonumberx(L, 4, &isnum); - luaL_argcheck(L, isnum, 4, "expected `y2` to be a number"); - x3 = lua_tonumberx(L, 5, &isnum); - luaL_argcheck(L, isnum, 5, "expected `x3` to be a number"); - y3 = lua_tonumberx(L, 6, &isnum); - luaL_argcheck(L, isnum, 6, "expected `y3` to be a number"); - color = lua_tonumberx(L, 7, &isnum); - luaL_argcheck(L, isnum && color >= 0 && color < 256, 7, "expected `color` to be a number within [0, 255]"); - - epd_fill_triangle(x1, y1, x2, y2, x3, y3, color, fb); - return 0; -} - -static int update (lua_State *L) { - int temperature = 25; - epd_poweron(); - epd_hl_update_screen(&hl, MODE_GC16, temperature); - epd_poweroff(); - return 0; -} - -static const struct luaL_Reg paper[] = { - {"init", init}, - {"clear", clear}, - - {"get_width", get_width}, - {"get_height", get_height}, - - {"set_rotation", set_rotation}, - {"get_rotation", get_rotation}, - - {"draw_pixel", draw_pixel}, - {"draw_line", draw_line}, - {"draw_hline", draw_hline}, - {"draw_vline", draw_vline}, - {"draw_circle", draw_circle}, - {"fill_circle", fill_circle}, - {"draw_rect", draw_rect}, - {"fill_rect", fill_rect}, - {"draw_triangle", draw_triangle}, - {"fill_triangle", fill_triangle}, - {"update", update}, - - {NULL, NULL}, -}; - -int luaopen_paper (lua_State *L) { - luaL_newlib(L, paper); - return 1; -} +int luaopen_paper (lua_State *L); #endif // PAPER_H_