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 " :param range: Pair of ints.\n"
33 " :type range: tuple[int, int]\n"
34 " :param coords: Sequence of bytes (6 floats for one triangle) for (X, Y) coordinates.\n"
35 " :type coords: bytes\n"
36 " :param colors: Sequence of bytes (12 for one triangle) 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 = {
55 if (!_PyArg_ParseTupleAndKeywordsFast(
56 args, kw, &_parser, &coords_range[0], &coords_range[1], &py_coords, &py_colors))
61 const int coords_len = PyBytes_GET_SIZE(py_coords);
62 const int tris_len = coords_len / 6;
63 if (tris_len * 6 != coords_len) {
64 PyErr_SetString(PyExc_ValueError,
"coords must be multiple of 6");
67 if (PyBytes_GET_SIZE(py_colors) != 2 * coords_len) {
68 PyErr_SetString(PyExc_ValueError,
"colors must be twice size of coords");
72 const size_t items_num = size_t(tris_len) * 3;
76 memcpy(coords, PyBytes_AS_STRING(py_coords),
sizeof(*coords) * items_num);
77 memcpy(colors, PyBytes_AS_STRING(py_colors),
sizeof(*colors) * items_num);
88 return PyLong_FromLong(icon_id);
93 bpy_app_icons_new_triangles_from_file_doc,
94 ".. function:: new_triangles_from_file(filepath)\n"
96 " Create a new icon from triangle geometry.\n"
98 " :param filepath: File path.\n"
99 " :type filepath: str | bytes\n"
100 " :return: Unique icon value (pass to interface ``icon_value`` argument).\n"
108 static const char *_keywords[] = {
"filepath",
nullptr};
109 static _PyArg_Parser _parser = {
111 ":new_triangles_from_file",
115 if (!_PyArg_ParseTupleAndKeywordsFast(
124 if (geom ==
nullptr) {
125 PyErr_SetString(PyExc_ValueError,
"Unable to load from file");
129 return PyLong_FromLong(icon_id);
134 bpy_app_icons_release_doc,
135 ".. function:: release(icon_id)\n"
137 " Release the icon.\n"
139 " :param icon_id: The icon id to release.\n"
140 " :type icon_id: int\n");
144 static const char *_keywords[] = {
"icon_id",
nullptr};
145 static _PyArg_Parser _parser = {
151 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &icon_id)) {
156 PyErr_SetString(PyExc_ValueError,
"invalid icon_id");
164# pragma clang diagnostic push
165# pragma clang diagnostic ignored "-Wcast-function-type"
167# pragma GCC diagnostic push
168# pragma GCC diagnostic ignored "-Wcast-function-type"
175 METH_VARARGS | METH_KEYWORDS,
176 bpy_app_icons_new_triangles_doc},
177 {
"new_triangles_from_file",
179 METH_VARARGS | METH_KEYWORDS,
180 bpy_app_icons_new_triangles_from_file_doc},
183 METH_VARARGS | METH_KEYWORDS,
184 bpy_app_icons_release_doc},
185 {
nullptr,
nullptr, 0,
nullptr},
190# pragma clang diagnostic pop
192# pragma GCC diagnostic pop
210 PyObject *sys_modules = PyImport_GetModuleDict();
Read Blender memory allocation and freeing.
VecBase< float, D > constexpr mod(VecOp< float, D >, VecOp< float, D >) RET
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
bool BKE_icon_delete_unmanaged(int icon_id)
static PyMethodDef M_AppIcons_methods[]
Icon_Geom * BKE_icon_geom_from_file(const char *filename)
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static PyModuleDef M_AppIcons_module_def
PyObject * BPY_app_icons_module()
PyDoc_STRVAR(bpy_bm_new_doc, ".. function:: new(*, use_operators=True)\n" "\n" " :param use_operators: Support calling operators in :mod:`bmesh.ops` (uses some " "extra memory per vert/edge/face).\n" " :type use_operators: bool\n" " :return: Return a new, empty BMesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n")
static PyObject * bpy_app_icons_new_triangles(PyObject *, PyObject *args, PyObject *kw)
static PyObject * bpy_app_icons_release(PyObject *, PyObject *args, PyObject *kw)
int PyC_ParseUnicodeAsBytesAndSize(PyObject *o, void *p)
int PyC_Module_AddToSysModules(PyObject *sys_modules, PyObject *module)
int BKE_icon_geom_ensure(Icon_Geom *geom)
static PyObject * bpy_app_icons_new_triangles_from_file(PyObject *, PyObject *args, PyObject *kw)
header-only compatibility defines.
const unsigned char * mem
unsigned char(* colors)[4]
unsigned char(* coords)[2]