tpt.drawline

This commit is contained in:
jacksonmj 2011-10-03 19:34:30 +01:00 committed by Simon Robertshaw
parent ae3241ec80
commit 4abefaf1ec
3 changed files with 33 additions and 2 deletions

View File

@ -47,6 +47,7 @@ int luatpt_get_property(lua_State* l);
int luatpt_drawpixel(lua_State* l); int luatpt_drawpixel(lua_State* l);
int luatpt_drawrect(lua_State* l); int luatpt_drawrect(lua_State* l);
int luatpt_fillrect(lua_State* l); int luatpt_fillrect(lua_State* l);
int luatpt_drawline(lua_State* l);
int luatpt_textwidth(lua_State* l); int luatpt_textwidth(lua_State* l);
int luatpt_get_name(lua_State* l); int luatpt_get_name(lua_State* l);
int luatpt_set_shortcuts(lua_State* l); int luatpt_set_shortcuts(lua_State* l);

View File

@ -1379,7 +1379,7 @@ inline void blendpixel(pixel *vid, int x, int y, int r, int g, int b, int a)
#endif #endif
{ {
#ifdef OpenGL #ifdef OpenGL
if (x<0 || y<0 || x>=XRES || r>=YRES) if (x<0 || y<0 || x>=XRES+BARSIZE || r>=YRES+MENUSIZE)
return; return;
if (a!=255) if (a!=255)
{ {
@ -1390,7 +1390,7 @@ inline void blendpixel(pixel *vid, int x, int y, int r, int g, int b, int a)
vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b); vid[y*(XRES+BARSIZE)+x] = PIXRGB(r,g,b);
#else #else
pixel t; pixel t;
if (x<0 || y<0 || x>=XRES || y>=YRES) if (x<0 || y<0 || x>=XRES+BARSIZE || y>=YRES+MENUSIZE)
return; return;
if (a!=255) if (a!=255)
{ {

View File

@ -30,6 +30,7 @@ void luacon_open(){
{"drawpixel", &luatpt_drawpixel}, {"drawpixel", &luatpt_drawpixel},
{"drawrect", &luatpt_drawrect}, {"drawrect", &luatpt_drawrect},
{"fillrect", &luatpt_fillrect}, {"fillrect", &luatpt_fillrect},
{"drawline", &luatpt_drawline},
{"textwidth", &luatpt_textwidth}, {"textwidth", &luatpt_textwidth},
{"get_name", &luatpt_get_name}, {"get_name", &luatpt_get_name},
{"set_shortcuts", &luatpt_set_shortcuts}, {"set_shortcuts", &luatpt_set_shortcuts},
@ -742,6 +743,35 @@ int luatpt_fillrect(lua_State* l)
return luaL_error(l, "Screen buffer does not exist"); return luaL_error(l, "Screen buffer does not exist");
} }
int luatpt_drawline(lua_State* l)
{
int x1,y1,x2,y2,r,g,b,a;
x1 = luaL_optint(l, 1, 0);
y1 = luaL_optint(l, 2, 0);
x2 = luaL_optint(l, 3, 10);
y2 = luaL_optint(l, 4, 10);
r = luaL_optint(l, 5, 255);
g = luaL_optint(l, 6, 255);
b = luaL_optint(l, 7, 255);
a = luaL_optint(l, 8, 255);
//Don't need to check coordinates, as they are checked in blendpixel
if (r<0) r = 0;
if (r>255) r = 255;
if (g<0) g = 0;
if (g>255) g = 255;
if (b<0) b = 0;
if (b>255) b = 255;
if (a<0) a = 0;
if (a>255) a = 255;
if (vid_buf!=NULL)
{
blend_line(vid_buf, x1, y1, x2, y2, r, g, b, a);
return 0;
}
return luaL_error(l, "Screen buffer does not exist");
}
int luatpt_textwidth(lua_State* l) int luatpt_textwidth(lua_State* l)
{ {
char * string; char * string;