summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-10-03 18:34:30 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-10-06 20:59:41 (GMT)
commit4abefaf1ec4e2545b87516340c4ab21b12d7f3ff (patch)
treed71ce3f542e293a12492b9b8c3147c27aa7839e4 /src
parentae3241ec80a252e86b8504304a3e03188d57022f (diff)
downloadpowder-4abefaf1ec4e2545b87516340c4ab21b12d7f3ff.zip
powder-4abefaf1ec4e2545b87516340c4ab21b12d7f3ff.tar.gz
tpt.drawline
Diffstat (limited to 'src')
-rw-r--r--src/graphics.c4
-rw-r--r--src/luaconsole.c30
2 files changed, 32 insertions, 2 deletions
diff --git a/src/graphics.c b/src/graphics.c
index 837dc42..eec5946 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 ad33041..5cc2bb3 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;