31 #include "../generic/py_capi_utils.h"
37 bpy_app_icons_new_triangles_doc,
38 ".. function:: new_triangles(range, coords, colors)"
40 " Create a new icon from triangle geometry.\n"
42 " :arg range: Pair of ints.\n"
43 " :type range: tuple.\n"
44 " :arg coords: Sequence of bytes (6 floats for one triangle) for (X, Y) coordinates.\n"
45 " :type coords: byte sequence.\n"
46 " :arg colors: Sequence of ints (12 for one triangles) for RGBA.\n"
47 " :type colors: byte sequence.\n"
48 " :return: Unique icon value (pass to interface ``icon_value`` argument).\n"
53 uchar coords_range[2];
54 PyObject *py_coords, *py_colors;
56 static const char *_keywords[] = {
"range",
"coords",
"colors",
NULL};
57 static _PyArg_Parser _parser = {
"(BB)SS:new_triangles", _keywords, 0};
58 if (!_PyArg_ParseTupleAndKeywordsFast(
59 args, kw, &_parser, &coords_range[0], &coords_range[1], &py_coords, &py_colors)) {
63 const int coords_len = PyBytes_GET_SIZE(py_coords);
64 const int tris_len = coords_len / 6;
65 if (tris_len * 6 != coords_len) {
66 PyErr_SetString(PyExc_ValueError,
"coords must be multiple of 6");
69 if (PyBytes_GET_SIZE(py_colors) != 2 * coords_len) {
70 PyErr_SetString(PyExc_ValueError,
"colors must be twice size of coords");
74 const int coords_size =
sizeof(
uchar[2]) * tris_len * 3;
75 const int colors_size =
sizeof(
uchar[4]) * tris_len * 3;
79 memcpy(coords, PyBytes_AS_STRING(py_coords), coords_size);
80 memcpy(colors, PyBytes_AS_STRING(py_colors), colors_size);
90 return PyLong_FromLong(
icon_id);
94 ".. function:: new_triangles_from_file(filename)"
96 " Create a new icon from triangle geometry.\n"
98 " :arg filename: File path.\n"
99 " :type filename: string.\n"
100 " :return: Unique icon value (pass to interface ``icon_value`` argument).\n"
109 static const char *_keywords[] = {
"filename",
NULL};
110 static _PyArg_Parser _parser = {
"s:new_triangles_from_file", _keywords, 0};
111 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &filename)) {
117 PyErr_SetString(PyExc_ValueError,
"Unable to load from file");
121 return PyLong_FromLong(
icon_id);
125 ".. function:: release(icon_id)"
127 " Release the icon.\n");
131 static const char *_keywords[] = {
"icon_id",
NULL};
132 static _PyArg_Parser _parser = {
"i:release", _keywords, 0};
133 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &
icon_id)) {
138 PyErr_SetString(PyExc_ValueError,
"invalid icon_id");
147 METH_VARARGS | METH_KEYWORDS,
148 bpy_app_icons_new_triangles_doc},
149 {
"new_triangles_from_file",
151 METH_VARARGS | METH_KEYWORDS,
152 bpy_app_icons_new_triangles_from_file_doc},
155 METH_VARARGS | METH_KEYWORDS,
156 bpy_app_icons_release_doc},
161 PyModuleDef_HEAD_INIT,
174 PyObject *sys_modules = PyImport_GetModuleDict();
178 PyDict_SetItem(sys_modules, PyModule_GetNameObject(
mod),
mod);
struct Icon_Geom * BKE_icon_geom_from_file(const char *filename)
int BKE_icon_geom_ensure(struct Icon_Geom *geom)
bool BKE_icon_delete_unmanaged(const int icon_id)
Read Guarded memory(de)allocation.
PyDoc_STRVAR(bpy_app_icons_new_triangles_doc, ".. function:: new_triangles(range, coords, colors)" "\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")
PyObject * BPY_app_icons_module(void)
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)