From 4abefaf1ec4e2545b87516340c4ab21b12d7f3ff Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Mon, 3 Oct 2011 19:34:30 +0100 Subject: [PATCH] tpt.drawline --- includes/luaconsole.h | 1 + src/graphics.c | 4 ++-- src/luaconsole.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/includes/luaconsole.h b/includes/luaconsole.h index 2a1df7a28..dc320ad13 100644 --- a/includes/luaconsole.h +++ b/includes/luaconsole.h @@ -47,6 +47,7 @@ int luatpt_get_property(lua_State* l); int luatpt_drawpixel(lua_State* l); int luatpt_drawrect(lua_State* l); int luatpt_fillrect(lua_State* l); +int luatpt_drawline(lua_State* l); int luatpt_textwidth(lua_State* l); int luatpt_get_name(lua_State* l); int luatpt_set_shortcuts(lua_State* l); diff --git a/src/graphics.c b/src/graphics.c index 837dc4211..eec594652 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1379,7 +1379,7 @@ inline void blendpixel(pixel *vid, int x, int y, int r, int g, int b, int a) #endif { #ifdef OpenGL - if (x<0 || y<0 || x>=XRES || r>=YRES) + if (x<0 || y<0 || x>=XRES+BARSIZE || r>=YRES+MENUSIZE) return; 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); #else pixel t; - if (x<0 || y<0 || x>=XRES || y>=YRES) + if (x<0 || y<0 || x>=XRES+BARSIZE || y>=YRES+MENUSIZE) return; if (a!=255) { diff --git a/src/luaconsole.c b/src/luaconsole.c index ad33041f9..5cc2bb3f1 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -30,6 +30,7 @@ void luacon_open(){ {"drawpixel", &luatpt_drawpixel}, {"drawrect", &luatpt_drawrect}, {"fillrect", &luatpt_fillrect}, + {"drawline", &luatpt_drawline}, {"textwidth", &luatpt_textwidth}, {"get_name", &luatpt_get_name}, {"set_shortcuts", &luatpt_set_shortcuts}, @@ -742,6 +743,35 @@ int luatpt_fillrect(lua_State* l) 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) { char * string;