Skip to content

Commit

Permalink
use tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasvlevi committed May 8, 2024
1 parent d6abfdf commit 9fc3718
Show file tree
Hide file tree
Showing 18 changed files with 909 additions and 931 deletions.
16 changes: 8 additions & 8 deletions src/bindings/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

int isKeyDown(lua_State *L)
{
int key = lua_tointeger(L, 1);
int key = lua_tointeger(L, 1);

bool down = false;
bool down = false;

if ((key > 0) && (key < MAX_KEYBOARD_KEYS))
{
down = (lu5.input.keyboard.current_keys[key] == 1);
}
if ((key > 0) && (key < MAX_KEYBOARD_KEYS))
{
down = (lu5.input.keyboard.current_keys[key] == 1);
}

lua_pushboolean(L, down);
return 1;
lua_pushboolean(L, down);
return 1;
}

16 changes: 8 additions & 8 deletions src/bindings/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

int print(lua_State *L)
{
int argc = lua_gettop(L);
// Print all arguments
for (int i = 1; i < argc; i++) {
lu5_print_any(L, i, 0, ' ');
}
lu5_print_any(L, argc, 0, '\n');
int argc = lua_gettop(L);
// Print all arguments
for (int i = 1; i < argc; i++) {
lu5_print_any(L, i, 0, ' ');
}
lu5_print_any(L, argc, 0, '\n');

return 0;
return 0;
}
46 changes: 23 additions & 23 deletions src/bindings/loaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,37 @@ int loadFont(lua_State *L) {
if (!str) {
luaL_error(L, "Expected first argument to be a string");

// Default font
lua_pushinteger(L, 0);
// Default font
lua_pushinteger(L, 0);
return 1;
}


int fontId = 0;
lu5_loadfont_err err = LOADFONT_NONE;
int fontId = 0;
lu5_loadfont_err err = LOADFONT_NONE;
if ((err = lu5_load_font(&lu5, str, &fontId)) != 0) {
switch(err) {
case LOADFONT_UNKNOWN: {
luaL_error(L, "Could not find font '%s'", str);
break;
}
case LOADFONT_UNKNOWN_FORMAT: {
luaL_error(L, "Unknown file format for '%s'", str);
break;
}
case LOADFONT_MAX: {
luaL_error(L, "Cannot load more than %d fonts", MAX_LOADED_FONTS);
break;
}
default: break;
}
// Default font
lua_pushinteger(L, 0);
switch(err) {
case LOADFONT_UNKNOWN: {
luaL_error(L, "Could not find font '%s'", str);
break;
}
case LOADFONT_UNKNOWN_FORMAT: {
luaL_error(L, "Unknown file format for '%s'", str);
break;
}
case LOADFONT_MAX: {
luaL_error(L, "Cannot load more than %d fonts", MAX_LOADED_FONTS);
break;
}
default: break;
}
// Default font
lua_pushinteger(L, 0);
return 1;
}

// Return the fontId
lua_pushinteger(L, fontId);
// Return the fontId
lua_pushinteger(L, fontId);
return 1;
}

Expand Down
40 changes: 20 additions & 20 deletions src/bindings/lu5_math.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,48 @@
#include <math.h>

int lu5_random(lua_State *L) {
luaL_error(L, "random not implemented");
return 1;
luaL_error(L, "random not implemented");
return 1;
}

int lu5_round(lua_State *L) {
double value = lua_tonumber(L, 1);
double value = lua_tonumber(L, 1);

lua_pushinteger(L, round(value));
return 1;
lua_pushinteger(L, round(value));
return 1;
}

int lu5_floor(lua_State *L) {
double value = lua_tonumber(L, 1);
double value = lua_tonumber(L, 1);

lua_pushinteger(L, floor(value));
return 1;
lua_pushinteger(L, floor(value));
return 1;
}

int lu5_ceil(lua_State *L) {
double value = lua_tonumber(L, 1);
double value = lua_tonumber(L, 1);

lua_pushinteger(L, ceil(value));
return 1;
lua_pushinteger(L, ceil(value));
return 1;
}

int lu5_sin(lua_State *L) {
double value = lua_tonumber(L, 1);
double value = lua_tonumber(L, 1);

lua_pushnumber(L, sin(value));
return 1;
lua_pushnumber(L, sin(value));
return 1;
}

int lu5_cos(lua_State *L) {
double value = lua_tonumber(L, 1);
double value = lua_tonumber(L, 1);

lua_pushnumber(L, cos(value));
return 1;
lua_pushnumber(L, cos(value));
return 1;
}

int lu5_tan(lua_State *L) {
double value = lua_tonumber(L, 1);
double value = lua_tonumber(L, 1);

lua_pushnumber(L, tan(value));
return 1;
lua_pushnumber(L, tan(value));
return 1;
}
56 changes: 28 additions & 28 deletions src/bindings/setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,70 +7,70 @@

int strokeWeight(lua_State *L)
{
double weight = lua_tonumber(L, 1);
double weight = lua_tonumber(L, 1);

glLineWidth(weight);
lu5.style.strokeWeight = weight;
glLineWidth(weight);
lu5.style.strokeWeight = weight;

return 0;
return 0;
}

int fill(lua_State *L)
{
lu5_color color = lu5_args_to_color(L);
lu5_color color = lu5_args_to_color(L);

lu5.style.fill = color;
lu5.style.fill = color;

return 0;
return 0;
}

int noFill(lua_State *L)
{
lu5.style.fill = (lu5_color){ .r=0, .g=0, .b=0, .a=0 };
lu5.style.fill = (lu5_color){ .r=0, .g=0, .b=0, .a=0 };

return 0;
return 0;
}

int stroke(lua_State *L)
{
lu5_color color = lu5_args_to_color(L);
lu5_color color = lu5_args_to_color(L);

lu5.style.stroke = color;
lu5.style.stroke = color;

return 0;
return 0;
}

int noStroke(lua_State *L)
{
lu5.style.stroke = (lu5_color){ .r=0, .g=0, .b=0, .a=0 };
lu5.style.stroke = (lu5_color){ .r=0, .g=0, .b=0, .a=0 };

return 0;
return 0;
}

int textSize(lua_State *L)
{
double size = lua_tonumber(L, 1);
double size = lua_tonumber(L, 1);

FT_Set_Char_Size(
lu5.fonts[lu5.style.fontId]->face,
0,
size * 64,
0,
0
);
FT_Set_Char_Size(
lu5.fonts[lu5.style.fontId]->face,
0,
size * 64,
0,
0
);

lu5.style.fontSize = size;
lu5.style.fontSize = size;

return 0;
return 0;
}


int textFont(lua_State *L)
{
int font_id = lua_tointeger(L, 1);
int font_id = lua_tointeger(L, 1);

lu5.style.fontId = font_id;
lu5.style.fontId = font_id;

return 0;
return 0;
}
Loading

0 comments on commit 9fc3718

Please sign in to comment.