More Lua functions: GetForeColor, GetBackColor, GetTransColor (layer translucency), and to read data from spare page: GetSparePictureSize, GetSpareColor (spare's palette), GetSpareTransColor, GetSpareLayerPixel (pixel from 'current layer' only of spare), GetSparePicturePixel (pixel from 'all visible layers' of spare)

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1336 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2010-02-12 02:57:00 +00:00
parent 25097afafd
commit 05d6d546a3

View File

@ -237,6 +237,63 @@ int L_GetLayerPixel(lua_State* L)
return 1;
}
// Spare
int L_GetSparePictureSize(lua_State* L)
{
lua_pushinteger(L, Spare_image_width);
lua_pushinteger(L, Spare_image_height);
return 2;
}
int L_GetSpareLayerPixel(lua_State* L)
{
int x = lua_tonumber(L,1);
int y = lua_tonumber(L,2);
// Bound check
if (x<0 || y<0 || x>=Spare_image_width || y>=Spare_image_height)
{
// Silently return the image's transparent color
lua_pushinteger(L, Spare_backups->Pages->Transparent_color);
return 1;
}
lua_pushinteger(L, *(Spare_backups->Pages->Image[Spare_current_layer] + y*Spare_image_width + x));
return 1;
}
int L_GetSparePicturePixel(lua_State* L)
{
int x = lua_tonumber(L,1);
int y = lua_tonumber(L,2);
// Some bound checking is done by the function itself, here's the rest.
if (x<0 || y<0)
{
// Silently return the image's transparent color
lua_pushinteger(L, Spare_backups->Pages->Transparent_color);
return 1;
}
lua_pushinteger(L, Read_pixel_from_spare_screen(x,y));
return 1;
}
int L_GetSpareColor(lua_State* L)
{
byte c=lua_tonumber(L,1);
lua_pushinteger(L, Spare_palette[c].R);
lua_pushinteger(L, Spare_palette[c].G);
lua_pushinteger(L, Spare_palette[c].B);
return 3;
}
int L_GetSpareTransColor(lua_State* L)
{
lua_pushinteger(L, Spare_backups->Pages->Transparent_color);
return 1;
}
int L_SetColor(lua_State* L)
{
byte c=lua_tonumber(L,1);
@ -284,6 +341,26 @@ int L_MatchColor(lua_State* L)
return 1;
}
int L_GetForeColor(lua_State* L)
{
lua_pushinteger(L, Fore_color);
return 1;
}
int L_GetBackColor(lua_State* L)
{
lua_pushinteger(L, Back_color);
return 1;
}
int L_GetTransColor(lua_State* L)
{
lua_pushinteger(L, Main_backups->Pages->Transparent_color);
return 1;
}
int L_InputBox(lua_State* L)
{
@ -681,6 +758,14 @@ void Button_Brush_Factory(void)
lua_register(L,"matchcolor",L_MatchColor);
lua_register(L,"getbrushtransparentcolor",L_GetBrushTransparentColor);
lua_register(L,"inputbox",L_InputBox);
lua_register(L,"getforecolor",L_GetForeColor);
lua_register(L,"getbackcolor",L_GetBackColor);
lua_register(L,"gettranscolor",L_GetTransColor);
lua_register(L,"getsparepicturesize ",L_GetSparePictureSize);
lua_register(L,"getsparelayerpixel ",L_GetSpareLayerPixel);
lua_register(L,"getsparepicturepixel",L_GetSparePicturePixel);
lua_register(L,"getsparecolor",L_GetSpareColor);
lua_register(L,"getsparetranscolor",L_GetSpareTransColor);
// For debug only