27 bpy_app_icons_new_triangles_doc,
28 ".. function:: new_triangles(range, coords, colors)\n"
30 " Create a new icon from triangle geometry.\n"
32 " :arg range: Pair of ints.\n"
33 " :type range: tuple[int, int]\n"
34 " :arg coords: Sequence of bytes (6 floats for one triangle) for (X, Y) coordinates.\n"
35 " :type coords: bytes\n"
36 " :arg colors: Sequence of bytes (12 for one triangles) for RGBA.\n"
37 " :type colors: bytes\n"
38 " :return: Unique icon value (pass to interface ``icon_value`` argument).\n"
43 uchar coords_range[2];
44 PyObject *py_coords, *py_colors;
46 static const char *_keywords[] = {
"range",
"coords",
"colors",
nullptr};
47 static _PyArg_Parser _parser = {
56 if (!_PyArg_ParseTupleAndKeywordsFast(
57 args, kw, &_parser, &coords_range[0], &coords_range[1], &py_coords, &py_colors))
62 const int coords_len = PyBytes_GET_SIZE(py_coords);
63 const int tris_len = coords_len / 6;
64 if (tris_len * 6 != coords_len) {
65 PyErr_SetString(PyExc_ValueError,
"coords must be multiple of 6");
68 if (PyBytes_GET_SIZE(py_colors) != 2 * coords_len) {
69 PyErr_SetString(PyExc_ValueError,
"colors must be twice size of coords");
73 const int coords_size =
sizeof(
uchar[2]) * tris_len * 3;
74 const int colors_size =
sizeof(
uchar[4]) * tris_len * 3;
78 memcpy(coords, PyBytes_AS_STRING(py_coords), coords_size);
79 memcpy(colors, PyBytes_AS_STRING(py_colors), colors_size);
89 return PyLong_FromLong(icon_id);
94 bpy_app_icons_new_triangles_from_file_doc,
95 ".. function:: new_triangles_from_file(filepath)\n"
97 " Create a new icon from triangle geometry.\n"
99 " :arg filepath: File path.\n"
100 " :type filepath: str | bytes.\n"
101 " :return: Unique icon value (pass to interface ``icon_value`` argument).\n"
109 static const char *_keywords[] = {
"filepath",
nullptr};
110 static _PyArg_Parser _parser = {
113 ":new_triangles_from_file",
117 if (!_PyArg_ParseTupleAndKeywordsFast(
126 if (geom ==
nullptr) {
127 PyErr_SetString(PyExc_ValueError,
"Unable to load from file");
131 return PyLong_FromLong(icon_id);
136 bpy_app_icons_release_doc,
137 ".. function:: release(icon_id)\n"
139 " Release the icon.\n");
143 static const char *_keywords[] = {
"icon_id",
nullptr};
144 static _PyArg_Parser _parser = {
151 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &icon_id)) {
156 PyErr_SetString(PyExc_ValueError,
"invalid icon_id");
162#if (defined(__GNUC__) && !defined(__clang__))
163# pragma GCC diagnostic push
164# pragma GCC diagnostic ignored "-Wcast-function-type"
170 METH_VARARGS | METH_KEYWORDS,
171 bpy_app_icons_new_triangles_doc},
172 {
"new_triangles_from_file",
174 METH_VARARGS | METH_KEYWORDS,
175 bpy_app_icons_new_triangles_from_file_doc},
178 METH_VARARGS | METH_KEYWORDS,
179 bpy_app_icons_release_doc},
180 {
nullptr,
nullptr, 0,
nullptr},
183#if (defined(__GNUC__) && !defined(__clang__))
184# pragma GCC diagnostic pop
188 PyModuleDef_HEAD_INIT,
201 PyObject *sys_modules = PyImport_GetModuleDict();
205 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)
void *(* MEM_mallocN)(size_t len, 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]
ccl_device_inline int mod(int x, int m)