diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..c970c92d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +# Contributing + +Add all the exposed lua bindings in `./src/bindings/*.h` + +Include your bindings in `./src/lu5_bindings.c` and register them to the lua state using `LUA_ADD_FUNCTION` macro + +Add a documentation comment for each lua binding. + +Build the application and the static documentation site. + +``` +make docs +``` + +Send a PR! \ No newline at end of file diff --git a/README.md b/README.md index c50e4148..877650e7 100644 --- a/README.md +++ b/README.md @@ -89,3 +89,11 @@ lu5 file.lua ![lu5 preview instances](./docs/assets/text_demo.png)
+ +--- + +### Contributions + +Contributions to expand the lu5 api are welcomed. + +Read the [contribution docs](./CONTRIBUTING.md) diff --git a/docs/assets/lu5_thumbnail.png b/docs/assets/lu5_thumbnail.png new file mode 100644 index 00000000..851671c6 Binary files /dev/null and b/docs/assets/lu5_thumbnail.png differ diff --git a/docs/index.html b/docs/index.html index 80b8e58d..533ff983 100644 --- a/docs/index.html +++ b/docs/index.html @@ -31,7 +31,7 @@

Reference

v0.0.2 -

setting

shapes

math

events

window

io

loaders

+

shapes

math

io

setting

events

window

loaders

diff --git a/examples/CONTRIBUTING.md b/examples/CONTRIBUTING.md new file mode 100644 index 00000000..e69de29b diff --git a/src/lu5_bindings.c b/src/lu5_bindings.c index ed94b195..96d8dbf0 100644 --- a/src/lu5_bindings.c +++ b/src/lu5_bindings.c @@ -11,104 +11,104 @@ #include "lu5_defs.h" void lu5_update_dynamic_variables(lua_State *L, GLFWwindow *window) { - double mouseX, mouseY; - glfwGetCursorPos(window, &mouseX, &mouseY); + double mouseX, mouseY; + glfwGetCursorPos(window, &mouseX, &mouseY); - int mouseIsPressed = glfwGetMouseButton(window, 0); + int mouseIsPressed = glfwGetMouseButton(window, 0); - LUA_ADD_CONST_NUMBER_GLOBAL(L, mouseX); - LUA_ADD_CONST_NUMBER_GLOBAL(L, mouseY); + LUA_ADD_CONST_NUMBER_GLOBAL(L, mouseX); + LUA_ADD_CONST_NUMBER_GLOBAL(L, mouseY); - LUA_ADD_CONST_BOOL_GLOBAL(L, mouseIsPressed); + LUA_ADD_CONST_BOOL_GLOBAL(L, mouseIsPressed); } static void lu5_register_constants(lua_State *L) { - LUA_ADD_NUMBER_GLOBAL(L, "LEFT_ARROW", 263); - LUA_ADD_NUMBER_GLOBAL(L, "RIGHT_ARROW", 262); - LUA_ADD_NUMBER_GLOBAL(L, "UP_ARROW", 265); - LUA_ADD_NUMBER_GLOBAL(L, "DOWN_ARROW", 264); - LUA_ADD_NUMBER_GLOBAL(L, "ENTER", 257); - LUA_ADD_NUMBER_GLOBAL(L, "BACKSPACE", 259); + LUA_ADD_NUMBER_GLOBAL(L, "LEFT_ARROW", 263); + LUA_ADD_NUMBER_GLOBAL(L, "RIGHT_ARROW", 262); + LUA_ADD_NUMBER_GLOBAL(L, "UP_ARROW", 265); + LUA_ADD_NUMBER_GLOBAL(L, "DOWN_ARROW", 264); + LUA_ADD_NUMBER_GLOBAL(L, "ENTER", 257); + LUA_ADD_NUMBER_GLOBAL(L, "BACKSPACE", 259); } void lu5_register_symbols(lua_State *L) { - LUA_ADD_STRING_GLOBAL(L, "VERSION", LU5_VERSION); + LUA_ADD_STRING_GLOBAL(L, "VERSION", LU5_VERSION); - LUA_ADD_FUNCTION(L, print); + LUA_ADD_FUNCTION(L, print); - LUA_ADD_FUNCTION(L, createWindow); - LUA_ADD_FUNCTION(L, background); + LUA_ADD_FUNCTION(L, createWindow); + LUA_ADD_FUNCTION(L, background); + + LUA_ADD_FUNCTION(L, isKeyDown); - LUA_ADD_FUNCTION(L, isKeyDown); - LUA_ADD_FUNCTION(L, fill); LUA_ADD_FUNCTION(L, noFill); LUA_ADD_FUNCTION(L, stroke); LUA_ADD_FUNCTION(L, noStroke); - LUA_ADD_FUNCTION(L, strokeWeight); - LUA_ADD_FUNCTION(L, textSize); - LUA_ADD_FUNCTION(L, textFont); + LUA_ADD_FUNCTION(L, strokeWeight); + LUA_ADD_FUNCTION(L, textSize); + LUA_ADD_FUNCTION(L, textFont); - LUA_ADD_FUNCTION(L, loadFont); + LUA_ADD_FUNCTION(L, loadFont); LUA_ADD_FUNCTION(L, point); - LUA_ADD_FUNCTION(L, circle); - LUA_ADD_FUNCTION(L, ellipse); - LUA_ADD_FUNCTION(L, square); - LUA_ADD_FUNCTION(L, rect); + LUA_ADD_FUNCTION(L, circle); + LUA_ADD_FUNCTION(L, ellipse); + LUA_ADD_FUNCTION(L, square); + LUA_ADD_FUNCTION(L, rect); LUA_ADD_FUNCTION(L, quad); - LUA_ADD_FUNCTION(L, line); + LUA_ADD_FUNCTION(L, line); LUA_ADD_FUNCTION(L, triangle); LUA_ADD_FUNCTION(L, text); LUA_ADD_FUNCTION(L, arc); - LUA_ADD_FUNCTION_BY_NAME(L, "round", lu5_round); - LUA_ADD_FUNCTION_BY_NAME(L, "ceil", lu5_ceil); - LUA_ADD_FUNCTION_BY_NAME(L, "floor", lu5_floor); - LUA_ADD_FUNCTION_BY_NAME(L, "sin", lu5_sin); - LUA_ADD_FUNCTION_BY_NAME(L, "cos", lu5_cos); - LUA_ADD_FUNCTION_BY_NAME(L, "tan", lu5_tan); + LUA_ADD_FUNCTION_BY_NAME(L, "round", lu5_round); + LUA_ADD_FUNCTION_BY_NAME(L, "ceil", lu5_ceil); + LUA_ADD_FUNCTION_BY_NAME(L, "floor", lu5_floor); + LUA_ADD_FUNCTION_BY_NAME(L, "sin", lu5_sin); + LUA_ADD_FUNCTION_BY_NAME(L, "cos", lu5_cos); + LUA_ADD_FUNCTION_BY_NAME(L, "tan", lu5_tan); lu5_register_constants(L); } void lu5_register_number_array(lua_State *L, const char* array_name, double *list, size_t size) { - lua_newtable(L); + lua_newtable(L); - for (int i = 0; i < size; i++) { - lua_pushnumber(L, i+1); - lua_pushnumber(L, list[i]); - lua_settable(L, -3); - } + for (int i = 0; i < size; i++) { + lua_pushnumber(L, i+1); + lua_pushnumber(L, list[i]); + lua_settable(L, -3); + } - lua_setglobal(L, array_name); + lua_setglobal(L, array_name); } void lu5_register_integer_array(lua_State *L, const char* array_name, int *list, size_t size) { - lua_newtable(L); + lua_newtable(L); - for (int i = 0; i < size; i++) { - lua_pushnumber(L, i+1); - lua_pushinteger(L, list[i]); - lua_settable(L, -3); - } + for (int i = 0; i < size; i++) { + lua_pushnumber(L, i+1); + lua_pushinteger(L, list[i]); + lua_settable(L, -3); + } - lua_setglobal(L, array_name); + lua_setglobal(L, array_name); } void lu5_register_string_array(lua_State *L, const char* array_name, const char **list, size_t size) { - lua_newtable(L); + lua_newtable(L); - for (int i = 0; i < size; i++) { - lua_pushnumber(L, i+1); - lua_pushstring(L, list[i]); - lua_settable(L, -3); - } + for (int i = 0; i < size; i++) { + lua_pushnumber(L, i+1); + lua_pushstring(L, list[i]); + lua_settable(L, -3); + } - lua_setglobal(L, array_name); + lua_setglobal(L, array_name); }