82 lines
2.2 KiB
C
82 lines
2.2 KiB
C
|
#define PY_SSIZE_T_CLEAN
|
||
|
#include <Python.h>
|
||
|
#include "scode.h"
|
||
|
#include "fbprimitive.h"
|
||
|
#include "ep_init.h"
|
||
|
|
||
|
static PyObject *do_setpixel(PyObject *self, PyObject *args)
|
||
|
{
|
||
|
INT32 x, y;
|
||
|
UINT16 color, oldcolor;
|
||
|
BOOL xor;
|
||
|
|
||
|
if (!PyArg_ParseTuple(args, "iiHi", &x, &y, &color, &xor))
|
||
|
return NULL;
|
||
|
oldcolor = Fb_setpixel(x, y, color, xor);
|
||
|
return PyLong_FromLong((long)oldcolor);
|
||
|
}
|
||
|
|
||
|
static PyObject *do_line(PyObject *self, PyObject *args)
|
||
|
{
|
||
|
INT32 x1, y1, x2, y2;
|
||
|
UINT16 color;
|
||
|
BOOL xor;
|
||
|
|
||
|
if (!PyArg_ParseTuple(args, "iiiiHi", &x1, &y1, &x2, &y2, &color, &xor))
|
||
|
return NULL;
|
||
|
Fb_line(x1, y1, x2, y2, color, xor);
|
||
|
Py_RETURN_NONE;
|
||
|
}
|
||
|
|
||
|
static PyObject *do_rectangle(PyObject *self, PyObject *args)
|
||
|
{
|
||
|
INT32 x1, y1, x2, y2;
|
||
|
UINT16 color;
|
||
|
BOOL xor;
|
||
|
|
||
|
if (!PyArg_ParseTuple(args, "iiiiHi", &x1, &y1, &x2, &y2, &color, &xor))
|
||
|
return NULL;
|
||
|
Fb_rectangle(x1, y1, x2, y2, color, xor);
|
||
|
Py_RETURN_NONE;
|
||
|
}
|
||
|
|
||
|
static PyObject *do_filled_rectangle(PyObject *self, PyObject *args)
|
||
|
{
|
||
|
INT32 x1, y1, x2, y2;
|
||
|
UINT16 color;
|
||
|
BOOL xor;
|
||
|
|
||
|
if (!PyArg_ParseTuple(args, "iiiiHi", &x1, &y1, &x2, &y2, &color, &xor))
|
||
|
return NULL;
|
||
|
Fb_filled_rectangle(x1, y1, x2, y2, color, xor);
|
||
|
Py_RETURN_NONE;
|
||
|
}
|
||
|
|
||
|
static PyMethodDef UPIWIN_tmpMethods[] = {
|
||
|
{"setpixel", do_setpixel, METH_VARARGS, "Set a single pixel on the display."},
|
||
|
{"line", do_line, METH_VARARGS, "Draw a line on the display."},
|
||
|
{"rectangle", do_rectangle, METH_VARARGS, "Draw a rectangle on the display."},
|
||
|
{"filled_rectangle", do_filled_rectangle, METH_VARARGS, "Draw a filled rectangle on the display."},
|
||
|
{NULL, NULL, 0, NULL}
|
||
|
};
|
||
|
|
||
|
static PyModuleDef DefUPIWIN_tmp = {
|
||
|
PyModuleDef_HEAD_INIT, /* standard garbage */
|
||
|
MOD_NAME_UPIWIN_TMP, /* module name */
|
||
|
NULL, /* no doc string */
|
||
|
-1, /* no per-module memory */
|
||
|
UPIWIN_tmpMethods, /* method defs */
|
||
|
NULL, /* no slots for multi-phase init */
|
||
|
NULL, /* no traversal proc */
|
||
|
NULL, /* no clear function */
|
||
|
NULL /* no free function */
|
||
|
};
|
||
|
|
||
|
PyObject *Epython_init_upiwin_tmp_module(void)
|
||
|
{
|
||
|
PyObject *module;
|
||
|
|
||
|
module = PyModule_Create(&DefUPIWIN);
|
||
|
return module;
|
||
|
}
|