17 #include "../generic/py_capi_utils.h"
23 bpy_app_icons_new_triangles_doc,
24 ".. function:: new_triangles(range, coords, colors)\n"
26 " Create a new icon from triangle geometry.\n"
28 " :arg range: Pair of ints.\n"
29 " :type range: tuple.\n"
30 " :arg coords: Sequence of bytes (6 floats for one triangle) for (X, Y) coordinates.\n"
31 " :type coords: byte sequence.\n"
32 " :arg colors: Sequence of ints (12 for one triangles) for RGBA.\n"
33 " :type colors: byte sequence.\n"
34 " :return: Unique icon value (pass to interface ``icon_value`` argument).\n"
39 uchar coords_range[2];
40 PyObject *py_coords, *py_colors;
42 static const char *_keywords[] = {
"range",
"coords",
"colors",
NULL};
43 static _PyArg_Parser _parser = {
51 if (!_PyArg_ParseTupleAndKeywordsFast(
52 args, kw, &_parser, &coords_range[0], &coords_range[1], &py_coords, &py_colors)) {
56 const int coords_len = PyBytes_GET_SIZE(py_coords);
57 const int tris_len = coords_len / 6;
58 if (tris_len * 6 != coords_len) {
59 PyErr_SetString(PyExc_ValueError,
"coords must be multiple of 6");
62 if (PyBytes_GET_SIZE(py_colors) != 2 * coords_len) {
63 PyErr_SetString(PyExc_ValueError,
"colors must be twice size of coords");
67 const int coords_size =
sizeof(
uchar[2]) * tris_len * 3;
68 const int colors_size =
sizeof(
uchar[4]) * tris_len * 3;
72 memcpy(coords, PyBytes_AS_STRING(py_coords), coords_size);
73 memcpy(colors, PyBytes_AS_STRING(py_colors), colors_size);
83 return PyLong_FromLong(
icon_id);
87 ".. function:: new_triangles_from_file(filename)\n"
89 " Create a new icon from triangle geometry.\n"
91 " :arg filename: File path.\n"
92 " :type filename: string.\n"
93 " :return: Unique icon value (pass to interface ``icon_value`` argument).\n"
102 static const char *_keywords[] = {
"filename",
NULL};
103 static _PyArg_Parser _parser = {
105 ":new_triangles_from_file",
109 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &filename)) {
115 PyErr_SetString(PyExc_ValueError,
"Unable to load from file");
119 return PyLong_FromLong(
icon_id);
123 ".. function:: release(icon_id)\n"
125 " Release the icon.\n");
129 static const char *_keywords[] = {
"icon_id",
NULL};
130 static _PyArg_Parser _parser = {
136 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &
icon_id)) {
141 PyErr_SetString(PyExc_ValueError,
"invalid icon_id");
150 METH_VARARGS | METH_KEYWORDS,
151 bpy_app_icons_new_triangles_doc},
152 {
"new_triangles_from_file",
154 METH_VARARGS | METH_KEYWORDS,
155 bpy_app_icons_new_triangles_from_file_doc},
158 METH_VARARGS | METH_KEYWORDS,
159 bpy_app_icons_release_doc},
164 PyModuleDef_HEAD_INIT,
177 PyObject *sys_modules = PyImport_GetModuleDict();
181 PyDict_SetItem(sys_modules, PyModule_GetNameObject(
mod),
mod);
struct Icon_Geom * BKE_icon_geom_from_file(const char *filename)
bool BKE_icon_delete_unmanaged(int icon_id)
int BKE_icon_geom_ensure(struct Icon_Geom *geom)
Read Guarded memory(de)allocation.
PyObject * BPY_app_icons_module(void)
PyDoc_STRVAR(bpy_app_icons_new_triangles_doc, ".. function:: new_triangles(range, coords, colors)\n" "\n" " Create a new icon from triangle geometry.\n" "\n" " :arg range: Pair of ints.\n" " :type range: tuple.\n" " :arg coords: Sequence of bytes (6 floats for one triangle) for (X, Y) coordinates.\n" " :type coords: byte sequence.\n" " :arg colors: Sequence of ints (12 for one triangles) for RGBA.\n" " :type colors: byte sequence.\n" " :return: Unique icon value (pass to interface ``icon_value`` argument).\n" " :rtype: int\n")
static PyObject * bpy_app_icons_release(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
static struct PyModuleDef M_AppIcons_module_def
static PyObject * bpy_app_icons_new_triangles(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
static PyObject * bpy_app_icons_new_triangles_from_file(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
static struct PyMethodDef M_AppIcons_methods[]
void *(* MEM_mallocN)(size_t len, const char *str)
unsigned char(* colors)[4]
unsigned char(* coords)[2]
ccl_device_inline int mod(int x, int m)