25 bpy_app_icons_new_triangles_doc,
26 ".. function:: new_triangles(range, coords, colors)\n"
28 " Create a new icon from triangle geometry.\n"
30 " :arg range: Pair of ints.\n"
31 " :type range: tuple[int, int]\n"
32 " :arg coords: Sequence of bytes (6 floats for one triangle) for (X, Y) coordinates.\n"
33 " :type coords: bytes\n"
34 " :arg colors: Sequence of bytes (12 for one triangles) for RGBA.\n"
35 " :type colors: bytes\n"
36 " :return: Unique icon value (pass to interface ``icon_value`` argument).\n"
41 uchar coords_range[2];
42 PyObject *py_coords, *py_colors;
44 static const char *_keywords[] = {
"range",
"coords",
"colors",
nullptr};
45 static _PyArg_Parser _parser = {
54 if (!_PyArg_ParseTupleAndKeywordsFast(
55 args, kw, &_parser, &coords_range[0], &coords_range[1], &py_coords, &py_colors))
60 const int coords_len = PyBytes_GET_SIZE(py_coords);
61 const int tris_len = coords_len / 6;
62 if (tris_len * 6 != coords_len) {
63 PyErr_SetString(PyExc_ValueError,
"coords must be multiple of 6");
66 if (PyBytes_GET_SIZE(py_colors) != 2 * coords_len) {
67 PyErr_SetString(PyExc_ValueError,
"colors must be twice size of coords");
71 const size_t items_num = size_t(tris_len) * 3;
75 memcpy(coords, PyBytes_AS_STRING(py_coords),
sizeof(*coords) * items_num);
76 memcpy(colors, PyBytes_AS_STRING(py_colors),
sizeof(*colors) * items_num);
86 return PyLong_FromLong(icon_id);
91 bpy_app_icons_new_triangles_from_file_doc,
92 ".. function:: new_triangles_from_file(filepath)\n"
94 " Create a new icon from triangle geometry.\n"
96 " :arg filepath: File path.\n"
97 " :type filepath: str | bytes.\n"
98 " :return: Unique icon value (pass to interface ``icon_value`` argument).\n"
106 static const char *_keywords[] = {
"filepath",
nullptr};
107 static _PyArg_Parser _parser = {
110 ":new_triangles_from_file",
114 if (!_PyArg_ParseTupleAndKeywordsFast(
123 if (geom ==
nullptr) {
124 PyErr_SetString(PyExc_ValueError,
"Unable to load from file");
128 return PyLong_FromLong(icon_id);
133 bpy_app_icons_release_doc,
134 ".. function:: release(icon_id)\n"
136 " Release the icon.\n");
140 static const char *_keywords[] = {
"icon_id",
nullptr};
141 static _PyArg_Parser _parser = {
148 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &icon_id)) {
153 PyErr_SetString(PyExc_ValueError,
"invalid icon_id");
161# pragma clang diagnostic push
162# pragma clang diagnostic ignored "-Wcast-function-type"
164# pragma GCC diagnostic push
165# pragma GCC diagnostic ignored "-Wcast-function-type"
172 METH_VARARGS | METH_KEYWORDS,
173 bpy_app_icons_new_triangles_doc},
174 {
"new_triangles_from_file",
176 METH_VARARGS | METH_KEYWORDS,
177 bpy_app_icons_new_triangles_from_file_doc},
180 METH_VARARGS | METH_KEYWORDS,
181 bpy_app_icons_release_doc},
182 {
nullptr,
nullptr, 0,
nullptr},
187# pragma clang diagnostic pop
189# pragma GCC diagnostic pop
207 PyObject *sys_modules = PyImport_GetModuleDict();
211 PyDict_SetItem(sys_modules, PyModule_GetNameObject(
mod),
mod);
bool BKE_icon_delete_unmanaged(int icon_id)
int BKE_icon_geom_ensure(struct Icon_Geom *geom)
struct Icon_Geom * BKE_icon_geom_from_file(const char *filename)
Read Guarded memory(de)allocation.
static PyObject * bpy_app_icons_new_triangles(PyObject *, PyObject *args, PyObject *kw)
PyObject * BPY_app_icons_module()
static PyModuleDef M_AppIcons_module_def
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[int, int]\n" " :arg coords: Sequence of bytes (6 floats for one triangle) for (X, Y) coordinates.\n" " :type coords: bytes\n" " :arg colors: Sequence of bytes (12 for one triangles) for RGBA.\n" " :type colors: bytes\n" " :return: Unique icon value (pass to interface ``icon_value`` argument).\n" " :rtype: int\n")
static PyObject * bpy_app_icons_release(PyObject *, PyObject *args, PyObject *kw)
static PyMethodDef M_AppIcons_methods[]
static PyObject * bpy_app_icons_new_triangles_from_file(PyObject *, PyObject *args, PyObject *kw)
VecBase< float, D > constexpr mod(VecOp< float, D >, VecOp< float, D >) RET
void * MEM_mallocN(size_t len, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
int PyC_ParseUnicodeAsBytesAndSize(PyObject *o, void *p)
header-only compatibility defines.
#define PY_ARG_PARSER_HEAD_COMPAT()
unsigned char(* colors)[4]
unsigned char(* coords)[2]