From d8234fcc1c0bf108a1ea23f70a14266e8cc2d71b Mon Sep 17 00:00:00 2001 From: James Nelson Date: Wed, 18 Apr 2018 14:23:09 -0600 Subject: [PATCH] Change color scale from 0 - 255 to 0 - 1.0 --- src/nuklear_love.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/nuklear_love.c b/src/nuklear_love.c index 7ee6353..e7e15b1 100644 --- a/src/nuklear_love.c +++ b/src/nuklear_love.c @@ -60,10 +60,10 @@ static void nk_love_configureGraphics(int line_thickness, struct nk_color col) lua_call(L, 1, 0); } lua_getfield(L, -1, "setColor"); - lua_pushnumber(L, col.r); - lua_pushnumber(L, col.g); - lua_pushnumber(L, col.b); - lua_pushnumber(L, col.a); + lua_pushnumber(L, col.r / 255.0); + lua_pushnumber(L, col.g / 255.0); + lua_pushnumber(L, col.b / 255.0); + lua_pushnumber(L, col.a / 255.0); lua_call(L, 4, 0); } @@ -77,10 +77,10 @@ static void nk_love_getGraphics(float *line_thickness, struct nk_color *color) lua_pop(L, 1); lua_getfield(L, -1, "getColor"); lua_call(L, 0, 4); - color->r = lua_tointeger(L, -4); - color->g = lua_tointeger(L, -3); - color->b = lua_tointeger(L, -2); - color->a = lua_tointeger(L, -1); + color->r = lua_tointeger(L, -4) * 255.0; + color->g = lua_tointeger(L, -3) * 255.0; + color->b = lua_tointeger(L, -2) * 255.0; + color->a = lua_tointeger(L, -1) * 255.0; lua_pop(L, 6); } @@ -255,10 +255,10 @@ static void nk_love_draw_text(int fontref, struct nk_color cbg, lua_getfield(L, -1, "graphics"); lua_getfield(L, -1, "setColor"); - lua_pushnumber(L, cbg.r); - lua_pushnumber(L, cbg.g); - lua_pushnumber(L, cbg.b); - lua_pushnumber(L, cbg.a); + lua_pushnumber(L, cbg.r / 255.0); + lua_pushnumber(L, cbg.g / 255.0); + lua_pushnumber(L, cbg.b / 255.0); + lua_pushnumber(L, cbg.a / 255.0); lua_call(L, 4, 0); lua_getfield(L, -1, "rectangle"); @@ -270,10 +270,10 @@ static void nk_love_draw_text(int fontref, struct nk_color cbg, lua_call(L, 5, 0); lua_getfield(L, -1, "setColor"); - lua_pushnumber(L, cfg.r); - lua_pushnumber(L, cfg.g); - lua_pushnumber(L, cfg.b); - lua_pushnumber(L, cfg.a); + lua_pushnumber(L, cfg.r / 255.0); + lua_pushnumber(L, cfg.g / 255.0); + lua_pushnumber(L, cfg.b / 255.0); + lua_pushnumber(L, cfg.a / 255.0); lua_call(L, 4, 0); lua_getfield(L, -1, "setFont"); @@ -318,9 +318,9 @@ static void nk_love_draw_rect_multi_color(int x, int y, unsigned int w, lua_pushstring(L, "all"); lua_call(L, 1, 0); lua_getfield(L, -1, "setColor"); - lua_pushnumber(L, 255); - lua_pushnumber(L, 255); - lua_pushnumber(L, 255); + lua_pushnumber(L, 1.0); + lua_pushnumber(L, 1.0); + lua_pushnumber(L, 1.0); lua_call(L, 3, 0); lua_getfield(L, -1, "setPointSize"); lua_pushnumber(L, 1); @@ -368,10 +368,10 @@ static void nk_love_clear(struct nk_color col) lua_getglobal(L, "love"); lua_getfield(L, -1, "graphics"); lua_getfield(L, -1, "clear"); - lua_pushnumber(L, col.r); - lua_pushnumber(L, col.g); - lua_pushnumber(L, col.b); - lua_pushnumber(L, col.a); + lua_pushnumber(L, col.r / 255.0); + lua_pushnumber(L, col.g / 255.0); + lua_pushnumber(L, col.b / 255.0); + lua_pushnumber(L, col.a / 255.0); lua_call(L, 4, 0); lua_pop(L, 2); }