summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLieuwe <lieuwemo@gmail.com>2011-03-05 16:50:05 (GMT)
committer Lieuwe <lieuwemo@gmail.com>2011-03-05 16:50:05 (GMT)
commit20b6a64228061a0b4689fcad439871e38ec88038 (patch)
treecdbf5010b511dc1e64cab451c27ddebcf5c9da0c /src
parent5cb538f08105d110a6dca6a7add9e10add20f978 (diff)
downloadpowder-20b6a64228061a0b4689fcad439871e38ec88038.zip
powder-20b6a64228061a0b4689fcad439871e38ec88038.tar.gz
moar graphics stuff
Diffstat (limited to 'src')
-rw-r--r--src/main.c46
-rw-r--r--src/python/tpt_console.py8
2 files changed, 51 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index eaa8674..04ba232 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1758,7 +1758,7 @@ emb_draw_pixel(PyObject *self, PyObject *args)
{
int x,y,r,g,b,a;
a=255;
- if(!PyArg_ParseTuple(args, "IIIII|I:drawpixel",&x,&y,&r,&g,&b,&a))
+ if(!PyArg_ParseTuple(args, "IIIII|I:draw_pixel",&x,&y,&r,&g,&b,&a))
return NULL;
if(vid_buf!=NULL)
@@ -1776,7 +1776,7 @@ emb_draw_text(PyObject *self, PyObject *args)
int x,y,r,g,b,a;
char *txt;
a=255;
- if(!PyArg_ParseTuple(args, "IIsIII|I:drawpixel",&x,&y,&txt,&r,&g,&b,&a))
+ if(!PyArg_ParseTuple(args, "IIsIII|I:draw_text",&x,&y,&txt,&r,&g,&b,&a))
return NULL;
if(vid_buf!=NULL)
{
@@ -1786,6 +1786,45 @@ emb_draw_text(PyObject *self, PyObject *args)
return Py_BuildValue("i",-1);
}
+//drawrect(pixel *vid, int x, int y, int w, int h, int r, int g, int b, int a)
+emb_draw_rect(PyObject *self, PyObject *args)
+{
+ int x,y,w,h,r,g,b,a;
+ a=255;
+ if(!PyArg_ParseTuple(args, "IIIIIII|I:draw_rect",&x,&y,&w,&h,&r,&g,&b,&a))
+ return NULL;
+ if(vid_buf!=NULL)
+ {
+ drawrect(vid_buf,x,y,w,h,r,g,b,a);
+ //fillrect
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
+}
+
+emb_draw_fillrect(PyObject *self, PyObject *args)
+{
+ int x,y,w,h,r,g,b,a;
+ a=255;
+ if(!PyArg_ParseTuple(args, "IIIIIII|I:draw_fillrect",&x,&y,&w,&h,&r,&g,&b,&a))
+ return NULL;
+ if(vid_buf!=NULL)
+ {
+ fillrect(vid_buf,x,y,w,h,r,g,b,a);
+ //fillrect
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
+}
+//int textwidth(char *s)
+emb_string_get_width(PyObject *self, PyObject *args)
+{
+ char *txt;
+ if(!PyArg_ParseTuple(args, "s:",&txt))
+ return NULL;
+ return Py_BuildValue("i",textwidth(txt));
+}
+
static PyMethodDef EmbMethods[] = { //WARNING! don't forget to register your function here!
{"create", emb_create, METH_VARARGS|METH_KEYWORDS, "create a particle."},
{"log", emb_log, METH_VARARGS, "logs an error string to the console."},
@@ -1813,6 +1852,9 @@ static PyMethodDef EmbMethods[] = { //WARNING! don't forget to register your fun
{"get_prop", emb_get_prop, METH_VARARGS, "get some properties."},
{"draw_pixel", emb_draw_pixel, METH_VARARGS, "draw a pixel."},
{"draw_text", emb_draw_text, METH_VARARGS, "draw some text."},
+ {"draw_rect", emb_draw_rect, METH_VARARGS, "draw a rect."},
+ {"draw_fillrect", emb_draw_fillrect, METH_VARARGS, "draw a rect."},
+ {"string_get_width", emb_string_get_width, METH_VARARGS, "get string width."},
{NULL, NULL, 0, NULL}
};
diff --git a/src/python/tpt_console.py b/src/python/tpt_console.py
index dfe34b7..eb70363 100644
--- a/src/python/tpt_console.py
+++ b/src/python/tpt_console.py
@@ -89,8 +89,14 @@ def step():
def _step():
try:
a=step.i
+ a=step.txt
except:
step.i=0
+ step.txt="!FUCK YEAH!"
#toggle_pause()
- tpt.draw_text(step.i%100+100,100,"FUCK YEAH!",255,255,255)
+ xx=50+abs(25-(step.i%50))
+ w=tpt.string_get_width(step.txt)+16
+ tpt.draw_fillrect(xx-8,92,w,32,0,0,0,128)
+ tpt.draw_rect(xx-8,92,w,32,255,255,255)
+ tpt.draw_text(xx,100,step.txt,255,255,255)
step.i+=1