mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 16:39:29 +00:00
Updated the sf2dlib and sftdlib; Added the gfx.color.hex() function; Added the New3DS CPU mode control.
As the color order of the sf2dlib changed, you have to change it in your code, or use the color.hex() function. To fix the problems, just change "0xRRGGBBAA" to "0xAABBGGRR". Also, the shader compiler changed to Picasso, so you'll need it in order to compile. https://github.com/fincs/picasso
This commit is contained in:
parent
0105970ab7
commit
b4d025d602
17 changed files with 205 additions and 131 deletions
|
|
@ -76,12 +76,32 @@ static int color_RGBA8(lua_State *L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/***
|
||||
Return a color from a hexadecimal value.
|
||||
@function hex
|
||||
@tparam integer hex the hexadecimal color code: 0xRRGGBBAA
|
||||
@treturn integer the color
|
||||
*/
|
||||
static int color_hex(lua_State *L) {
|
||||
u32 hex = luaL_checkinteger(L, 1);
|
||||
|
||||
u8 r = (hex & 0xFF000000) >> 24;
|
||||
u8 g = (hex & 0x00FF0000) >> 16;
|
||||
u8 b = (hex & 0x0000FF00) >> 8;
|
||||
u8 a = (hex & 0x000000FF);
|
||||
|
||||
lua_pushinteger(L, RGBA8(r, g, b, a));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct luaL_Reg color_lib[] = {
|
||||
{ "setDefault", color_setDefault },
|
||||
{ "getDefault", color_getDefault },
|
||||
{ "setBackground", color_setBackground },
|
||||
{ "getBackground", color_getBackground },
|
||||
{ "RGBA8", color_RGBA8 },
|
||||
{ "hex", color_hex },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
@ -92,4 +112,4 @@ int luaopen_color_lib(lua_State *L) {
|
|||
|
||||
void load_color_lib(lua_State *L) {
|
||||
luaL_requiref(L, "ctr.gfx.color", luaopen_color_lib, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue