diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-02-28 17:57:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-02-28 17:57:26 +0300 |
commit | ed7f4f2e3cc19e6c90b678b87617d2a19ddc3da3 (patch) | |
tree | 9cd8cb96e8e34d5f0a9d96785a5ce028e8d5c21f /source/blender/python/generic/blf.c | |
parent | c1cd33e166fa0b0f9419ec9d8a19d124452019d3 (diff) |
make BGL and BLF modile names lowercase
Diffstat (limited to 'source/blender/python/generic/blf.c')
-rw-r--r-- | source/blender/python/generic/blf.c | 196 |
1 files changed, 196 insertions, 0 deletions
diff --git a/source/blender/python/generic/blf.c b/source/blender/python/generic/blf.c new file mode 100644 index 00000000000..52fe860f988 --- /dev/null +++ b/source/blender/python/generic/blf.c @@ -0,0 +1,196 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <Python.h> +#include "blf.h" + +#include "../../blenfont/BLF_api.h" + +static char py_blf_position_doc[] = +".. function:: position(x, y, z)\n" +"\n" +" Set the position for drawing text."; + +static PyObject *py_blf_position(PyObject *self, PyObject *args) +{ + float x, y, z; + + if (!PyArg_ParseTuple(args, "fff:BLF.position", &x, &y, &z)) + return NULL; + + BLF_position(x, y, z); + + Py_RETURN_NONE; +} + + +static char py_blf_size_doc[] = +".. function:: size(size, dpi)\n" +"\n" +" Set the size and dpi for drawing text.\n" +"\n" +" :arg size: Point size of the font.\n" +" :type size: int\n" +" :arg dpi: dots per inch value to use for drawing.\n" +" :type dpi: int\n"; + +static PyObject *py_blf_size(PyObject *self, PyObject *args) +{ + int size, dpi; + + if (!PyArg_ParseTuple(args, "ii:BLF.size", &size, &dpi)) + return NULL; + + BLF_size(size, dpi); + + Py_RETURN_NONE; +} + + +static char py_blf_aspect_doc[] = +".. function:: aspect(aspect)\n" +"\n" +" Set the aspect for drawing text.\n" +"\n" +" :arg aspect: The aspect ratio for text drawing to use.\n" +" :type aspect: float\n"; + +static PyObject *py_blf_aspect(PyObject *self, PyObject *args) +{ + float aspect; + + if (!PyArg_ParseTuple(args, "f:BLF.aspect", &aspect)) + return NULL; + + BLF_aspect(aspect); + + Py_RETURN_NONE; +} + + +static char py_blf_blur_doc[] = +".. function:: blur(radius)\n" +"\n" +" Set the blur radius for drawing text.\n" +"\n" +" :arg radius: The radius for blurring text (in pixels).\n" +" :type radius: int\n"; + +static PyObject *py_blf_blur(PyObject *self, PyObject *args) +{ + int blur; + + if (!PyArg_ParseTuple(args, "i:BLF.blur", &blur)) + return NULL; + + BLF_blur(blur); + + Py_RETURN_NONE; +} + + +static char py_blf_draw_doc[] = +".. function:: draw(text)\n" +"\n" +" Draw text in the current context.\n" +"\n" +" :arg text: the text to draw.\n" +" :type text: string\n"; + +static PyObject *py_blf_draw(PyObject *self, PyObject *args) +{ + char *text; + + if (!PyArg_ParseTuple(args, "s:BLF.draw", &text)) + return NULL; + + BLF_draw(text); + + Py_RETURN_NONE; +} + +static char py_blf_dimensions_doc[] = +".. function:: dimensions(text)\n" +"\n" +" Return the width and hight of the text.\n" +"\n" +" :arg text: the text to draw.\n" +" :type text: string\n" +" :return: the width and height of the text.\n" +" :rtype: tuple of 2 floats\n"; + +static PyObject *py_blf_dimensions(PyObject *self, PyObject *args) +{ + char *text; + float r_width, r_height; + PyObject *ret; + + if (!PyArg_ParseTuple(args, "s:BLF.dimensions", &text)) + return NULL; + + BLF_width_and_height(text, &r_width, &r_height); + + ret= PyTuple_New(2); + PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(r_width)); + PyTuple_SET_ITEM(ret, 1, PyFloat_FromDouble(r_height)); + return ret; +} + +/*----------------------------MODULE INIT-------------------------*/ +struct PyMethodDef BLF_methods[] = { + {"position", (PyCFunction)py_blf_position, METH_VARARGS, py_blf_position_doc}, + {"size", (PyCFunction) py_blf_size, METH_VARARGS, py_blf_size_doc}, + {"aspect", (PyCFunction) py_blf_aspect, METH_VARARGS, py_blf_aspect_doc}, + {"blur", (PyCFunction) py_blf_blur, METH_VARARGS, py_blf_blur_doc}, + + {"draw", (PyCFunction) py_blf_draw, METH_VARARGS, py_blf_draw_doc}, + + {"dimensions", (PyCFunction) py_blf_dimensions, METH_VARARGS, py_blf_dimensions_doc}, + {NULL, NULL, 0, NULL} +}; + +static char BLF_doc[] = +"This module provides access to blenders text drawing functions.\n"; + +static struct PyModuleDef BLF_module_def = { + PyModuleDef_HEAD_INIT, + "blf", /* m_name */ + BLF_doc, /* m_doc */ + 0, /* m_size */ + BLF_methods, /* m_methods */ + 0, /* m_reload */ + 0, /* m_traverse */ + 0, /* m_clear */ + 0, /* m_free */ +}; + +PyObject *BLF_Init(void) +{ + PyObject *submodule; + + submodule = PyModule_Create(&BLF_module_def); + PyDict_SetItemString(PySys_GetObject("modules"), BLF_module_def.m_name, submodule); + + return (submodule); +} |