LuaBox
Loading...
Searching...
No Matches
RGB.h
Go to the documentation of this file.
1#pragma once
2
3#include "lua_include.h"
4#include "global.h"
5
15
16int RGB(lua_State* L_)
17{
18 int r = luaL_checkinteger(L_, 1);
19 int g = luaL_checkinteger(L_, 2);
20 int b = luaL_checkinteger(L_, 3);
21
22 if (r < 0) r = 0; else if (r > 255) r = 255;
23 if (g < 0) g = 0; else if (g > 255) g = 255;
24 if (b < 0) b = 0; else if (b > 255) b = 255;
25
26 uint16_t color = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
27
28 lua_pushinteger(L_, color);
29 return 1;
30}
int RGB(lua_State *L_)
Convert 8-bit RGB values to 16-bit RGB565 color.
Definition RGB.h:16