42 "Class to define a set of attributes associated with a :class:`StrokeVertex`.\n"
43 "The attribute set stores the color, alpha and thickness values for a Stroke\n"
46 ".. method:: __init__()\n"
47 " __init__(brother)\n"
48 " __init__(red, green, blue, alpha, thickness_right, thickness_left)\n"
49 " __init__(attribute1, attribute2, t)\n"
51 " Creates a :class:`StrokeAttribute` object using either a default constructor,\n"
52 " copy constructor, overloaded constructor, or and interpolation constructor\n"
53 " to interpolate between two :class:`StrokeAttribute` objects.\n"
55 " :arg brother: A StrokeAttribute object to be used as a copy constructor.\n"
56 " :type brother: :class:`StrokeAttribute`\n"
57 " :arg red: Red component of a stroke color.\n"
59 " :arg green: Green component of a stroke color.\n"
60 " :type green: float\n"
61 " :arg blue: Blue component of a stroke color.\n"
62 " :type blue: float\n"
63 " :arg alpha: Alpha component of a stroke color.\n"
64 " :type alpha: float\n"
65 " :arg thickness_right: Stroke thickness on the right.\n"
66 " :type thickness_right: float\n"
67 " :arg thickness_left: Stroke thickness on the left.\n"
68 " :type thickness_left: float\n"
69 " :arg attribute1: The first StrokeAttribute object.\n"
70 " :type attribute1: :class:`StrokeAttribute`\n"
71 " :arg attribute2: The second StrokeAttribute object.\n"
72 " :type attribute2: :class:`StrokeAttribute`\n"
73 " :arg t: The interpolation parameter (0 <= t <= 1).\n"
78 static const char *kwlist_1[] = {
"brother",
nullptr};
79 static const char *kwlist_2[] = {
"attribute1",
"attribute2",
"t",
nullptr};
80 static const char *kwlist_3[] = {
81 "red",
"green",
"blue",
"alpha",
"thickness_right",
"thickness_left",
nullptr};
82 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
83 float red,
green, blue, alpha, thickness_right, thickness_left, t;
85 if (PyArg_ParseTupleAndKeywords(
95 else if ((
void)PyErr_Clear(),
96 PyArg_ParseTupleAndKeywords(args,
109 else if ((
void)PyErr_Clear(),
110 PyArg_ParseTupleAndKeywords(args,
124 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
127 self->borrowed =
false;
136 Py_TYPE(
self)->tp_free((PyObject *)
self);
141 stringstream repr(
"StrokeAttribute:");
142 repr <<
" r: " <<
self->sa->getColorR() <<
" g: " <<
self->sa->getColorG()
143 <<
" b: " <<
self->sa->getColorB() <<
" a: " <<
self->sa->getAlpha()
144 <<
" - R: " <<
self->sa->getThicknessR() <<
" L: " <<
self->sa->getThicknessL();
146 return PyUnicode_FromString(repr.str().c_str());
151 StrokeAttribute_get_attribute_real_doc,
152 ".. method:: get_attribute_real(name)\n"
154 " Returns an attribute of float type.\n"
156 " :arg name: The name of the attribute.\n"
158 " :return: The attribute value.\n"
165 static const char *kwlist[] = {
"name",
nullptr};
168 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
171 double a =
self->sa->getAttributeReal(attr);
172 return PyFloat_FromDouble(a);
177 StrokeAttribute_get_attribute_vec2_doc,
178 ".. method:: get_attribute_vec2(name)\n"
180 " Returns an attribute of two-dimensional vector type.\n"
182 " :arg name: The name of the attribute.\n"
184 " :return: The attribute value.\n"
185 " :rtype: :class:`mathutils.Vector`\n");
191 static const char *kwlist[] = {
"name",
nullptr};
194 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
197 Vec2f a =
self->sa->getAttributeVec2f(attr);
203 StrokeAttribute_get_attribute_vec3_doc,
204 ".. method:: get_attribute_vec3(name)\n"
206 " Returns an attribute of three-dimensional vector type.\n"
208 " :arg name: The name of the attribute.\n"
210 " :return: The attribute value.\n"
211 " :rtype: :class:`mathutils.Vector`\n");
217 static const char *kwlist[] = {
"name",
nullptr};
220 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
223 Vec3f a =
self->sa->getAttributeVec3f(attr);
229 StrokeAttribute_has_attribute_real_doc,
230 ".. method:: has_attribute_real(name)\n"
232 " Checks whether the attribute name of float type is available.\n"
234 " :arg name: The name of the attribute.\n"
236 " :return: True if the attribute is available.\n"
243 static const char *kwlist[] = {
"name",
nullptr};
246 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
254 StrokeAttribute_has_attribute_vec2_doc,
255 ".. method:: has_attribute_vec2(name)\n"
257 " Checks whether the attribute name of two-dimensional vector type\n"
260 " :arg name: The name of the attribute.\n"
262 " :return: True if the attribute is available.\n"
269 static const char *kwlist[] = {
"name",
nullptr};
272 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
280 StrokeAttribute_has_attribute_vec3_doc,
281 ".. method:: has_attribute_vec3(name)\n"
283 " Checks whether the attribute name of three-dimensional vector\n"
284 " type is available.\n"
286 " :arg name: The name of the attribute.\n"
288 " :return: True if the attribute is available.\n"
295 static const char *kwlist[] = {
"name",
nullptr};
298 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
306 StrokeAttribute_set_attribute_real_doc,
307 ".. method:: set_attribute_real(name, value)\n"
309 " Adds a user-defined attribute of float type. If there is no\n"
310 " attribute of the given name, it is added. Otherwise, the new value\n"
311 " replaces the old one.\n"
313 " :arg name: The name of the attribute.\n"
315 " :arg value: The attribute value.\n"
316 " :type value: float\n");
322 static const char *kwlist[] = {
"name",
"value",
nullptr};
326 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"sd", (
char **)kwlist, &s, &d)) {
329 self->sa->setAttributeReal(s, d);
335 StrokeAttribute_set_attribute_vec2_doc,
336 ".. method:: set_attribute_vec2(name, value)\n"
338 " Adds a user-defined attribute of two-dimensional vector type. If\n"
339 " there is no attribute of the given name, it is added. Otherwise,\n"
340 " the new value replaces the old one.\n"
342 " :arg name: The name of the attribute.\n"
344 " :arg value: The attribute value.\n"
345 " :type value: :class:`mathutils.Vector` | tuple[float, float, float] | list[float]\n");
351 static const char *kwlist[] = {
"name",
"value",
nullptr};
353 PyObject *obj =
nullptr;
356 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"sO", (
char **)kwlist, &s, &obj)) {
360 PyErr_SetString(PyExc_TypeError,
361 "argument 2 must be a 2D vector (either a list of 2 elements or Vector)");
364 self->sa->setAttributeVec2f(s, vec);
370 StrokeAttribute_set_attribute_vec3_doc,
371 ".. method:: set_attribute_vec3(name, value)\n"
373 " Adds a user-defined attribute of three-dimensional vector type.\n"
374 " If there is no attribute of the given name, it is added.\n"
375 " Otherwise, the new value replaces the old one.\n"
377 " :arg name: The name of the attribute.\n"
379 " :arg value: The attribute value as a 3D vector.\n"
380 " :type value: :class:`mathutils.Vector` | tuple[float, float, float] | list[float]\n");
386 static const char *kwlist[] = {
"name",
"value",
nullptr};
388 PyObject *obj =
nullptr;
391 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"sO", (
char **)kwlist, &s, &obj)) {
395 PyErr_SetString(PyExc_TypeError,
396 "argument 2 must be a 3D vector (either a list of 3 elements or Vector)");
399 self->sa->setAttributeVec3f(s, vec);
404 {
"get_attribute_real",
406 METH_VARARGS | METH_KEYWORDS,
407 StrokeAttribute_get_attribute_real_doc},
408 {
"get_attribute_vec2",
410 METH_VARARGS | METH_KEYWORDS,
411 StrokeAttribute_get_attribute_vec2_doc},
412 {
"get_attribute_vec3",
414 METH_VARARGS | METH_KEYWORDS,
415 StrokeAttribute_get_attribute_vec3_doc},
416 {
"has_attribute_real",
418 METH_VARARGS | METH_KEYWORDS,
419 StrokeAttribute_has_attribute_real_doc},
420 {
"has_attribute_vec2",
422 METH_VARARGS | METH_KEYWORDS,
423 StrokeAttribute_has_attribute_vec2_doc},
424 {
"has_attribute_vec3",
426 METH_VARARGS | METH_KEYWORDS,
427 StrokeAttribute_has_attribute_vec3_doc},
428 {
"set_attribute_real",
430 METH_VARARGS | METH_KEYWORDS,
431 StrokeAttribute_set_attribute_real_doc},
432 {
"set_attribute_vec2",
434 METH_VARARGS | METH_KEYWORDS,
435 StrokeAttribute_set_attribute_vec2_doc},
436 {
"set_attribute_vec3",
438 METH_VARARGS | METH_KEYWORDS,
439 StrokeAttribute_set_attribute_vec3_doc},
440 {
nullptr,
nullptr, 0,
nullptr},
446#define MATHUTILS_SUBTYPE_COLOR 1
447#define MATHUTILS_SUBTYPE_THICKNESS 2
462 bmo->data[0] =
self->sa->getColorR();
463 bmo->data[1] =
self->sa->getColorG();
464 bmo->data[2] =
self->sa->getColorB();
467 bmo->data[0] =
self->sa->getThicknessR();
468 bmo->data[1] =
self->sa->getThicknessL();
481 self->sa->setColor(bmo->data[0], bmo->data[1], bmo->data[2]);
484 self->sa->setThickness(bmo->data[0], bmo->data[1]);
499 bmo->data[0] =
self->sa->getColorR();
502 bmo->data[1] =
self->sa->getColorG();
505 bmo->data[2] =
self->sa->getColorB();
514 bmo->data[0] =
self->sa->getThicknessR();
517 bmo->data[1] =
self->sa->getThicknessL();
534 float r = (index == 0) ? bmo->data[0] :
self->sa->getColorR();
535 float g = (index == 1) ? bmo->data[1] :
self->sa->getColorG();
536 float b = (index == 2) ? bmo->data[2] :
self->sa->getColorB();
537 self->sa->setColor(r, g,
b);
541 float tr = (index == 0) ? bmo->data[0] :
self->sa->getThicknessR();
542 float tl = (index == 1) ? bmo->data[1] :
self->sa->getThicknessL();
543 self->sa->setThickness(tr, tl);
571 StrokeAttribute_alpha_doc,
572 "Alpha component of the stroke color.\n"
578 return PyFloat_FromDouble(
self->sa->getAlpha());
586 if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
588 PyErr_SetString(PyExc_TypeError,
"value must be a number");
591 self->sa->setAlpha(scalar);
597 StrokeAttribute_color_doc,
598 "RGB components of the stroke color.\n"
600 ":type: :class:`mathutils.Color`");
616 self->sa->setColor(
v[0],
v[1],
v[2]);
622 StrokeAttribute_thickness_doc,
623 "Right and left components of the stroke thickness.\n"
624 "The right (left) component is the thickness on the right (left) of the vertex\n"
625 "when following the stroke.\n"
627 ":type: :class:`mathutils.Vector`");
643 self->sa->setThickness(
v[0],
v[1]);
649 StrokeAttribute_visible_doc,
650 "The visibility flag. True if the StrokeVertex is visible.\n"
663 if (!PyBool_Check(value)) {
664 PyErr_SetString(PyExc_TypeError,
"value must be boolean");
675 StrokeAttribute_alpha_doc,
680 StrokeAttribute_color_doc,
685 StrokeAttribute_thickness_doc,
690 StrokeAttribute_visible_doc,
692 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
698 PyVarObject_HEAD_INIT(
nullptr, 0)
717 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
bool bool_from_PyBool(PyObject *b)
bool Vec3f_ptr_from_PyObject(PyObject *obj, Vec3f &vec)
bool Vec2f_ptr_from_PyObject(PyObject *obj, Vec2f &vec)
PyObject * Vector_from_Vec3f(Vec3f &vec)
PyObject * Vector_from_Vec2f(Vec2f &vec)
PyObject * PyBool_from_bool(bool b)
static int StrokeAttribute_alpha_set(BPy_StrokeAttribute *self, PyObject *value, void *)
static int StrokeAttribute_init(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static int StrokeAttribute_visible_set(BPy_StrokeAttribute *self, PyObject *value, void *)
static PyObject * StrokeAttribute_get_attribute_vec3(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static int StrokeAttribute_thickness_set(BPy_StrokeAttribute *self, PyObject *value, void *)
static PyObject * StrokeAttribute_has_attribute_real(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static int StrokeAttribute_mathutils_set(BaseMathObject *bmo, int subtype)
PyTypeObject StrokeAttribute_Type
static PyObject * StrokeAttribute_set_attribute_real(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static PyObject * StrokeAttribute_has_attribute_vec2(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
#define MATHUTILS_SUBTYPE_THICKNESS
static PyObject * StrokeAttribute_visible_get(BPy_StrokeAttribute *self, void *)
static int StrokeAttribute_mathutils_get_index(BaseMathObject *bmo, int subtype, int index)
static PyObject * StrokeAttribute_get_attribute_vec2(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static PyObject * StrokeAttribute_color_get(BPy_StrokeAttribute *self, void *)
void StrokeAttribute_mathutils_register_callback()
static PyObject * StrokeAttribute_has_attribute_vec3(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static PyMethodDef BPy_StrokeAttribute_methods[]
static Mathutils_Callback StrokeAttribute_mathutils_cb
static PyGetSetDef BPy_StrokeAttribute_getseters[]
static PyObject * StrokeAttribute_repr(BPy_StrokeAttribute *self)
static PyObject * StrokeAttribute_set_attribute_vec3(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
PyDoc_STRVAR(StrokeAttribute_doc, "Class to define a set of attributes associated with a :class:`StrokeVertex`.\n" "The attribute set stores the color, alpha and thickness values for a Stroke\n" "Vertex.\n" "\n" ".. method:: __init__()\n" " __init__(brother)\n" " __init__(red, green, blue, alpha, thickness_right, thickness_left)\n" " __init__(attribute1, attribute2, t)\n" "\n" " Creates a :class:`StrokeAttribute` object using either a default constructor,\n" " copy constructor, overloaded constructor, or and interpolation constructor\n" " to interpolate between two :class:`StrokeAttribute` objects.\n" "\n" " :arg brother: A StrokeAttribute object to be used as a copy constructor.\n" " :type brother: :class:`StrokeAttribute`\n" " :arg red: Red component of a stroke color.\n" " :type red: float\n" " :arg green: Green component of a stroke color.\n" " :type green: float\n" " :arg blue: Blue component of a stroke color.\n" " :type blue: float\n" " :arg alpha: Alpha component of a stroke color.\n" " :type alpha: float\n" " :arg thickness_right: Stroke thickness on the right.\n" " :type thickness_right: float\n" " :arg thickness_left: Stroke thickness on the left.\n" " :type thickness_left: float\n" " :arg attribute1: The first StrokeAttribute object.\n" " :type attribute1: :class:`StrokeAttribute`\n" " :arg attribute2: The second StrokeAttribute object.\n" " :type attribute2: :class:`StrokeAttribute`\n" " :arg t: The interpolation parameter (0 <= t <= 1).\n" " :type t: float\n")
static PyObject * StrokeAttribute_thickness_get(BPy_StrokeAttribute *self, void *)
static PyObject * StrokeAttribute_alpha_get(BPy_StrokeAttribute *self, void *)
static int StrokeAttribute_mathutils_check(BaseMathObject *bmo)
static int StrokeAttribute_mathutils_get(BaseMathObject *bmo, int subtype)
static int StrokeAttribute_color_set(BPy_StrokeAttribute *self, PyObject *value, void *)
static PyObject * StrokeAttribute_get_attribute_real(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
#define MATHUTILS_SUBTYPE_COLOR
static PyObject * StrokeAttribute_set_attribute_vec2(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static int StrokeAttribute_mathutils_set_index(BaseMathObject *bmo, int subtype, int index)
static uchar StrokeAttribute_mathutils_cb_index
static void StrokeAttribute_dealloc(BPy_StrokeAttribute *self)
int StrokeAttribute_Init(PyObject *module)
#define BPy_StrokeAttribute_Check(v)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a producing a negative Combine Generate a color from its red
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a producing a negative Combine Generate a color from its green
ATTR_WARN_UNUSED_RESULT const BMVert * v
local_group_size(16, 16) .push_constant(Type b
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
uchar Mathutils_RegisterCallback(Mathutils_Callback *cb)
PyObject * Color_CreatePyObject_cb(PyObject *cb_user, uchar cb_type, uchar cb_subtype)
PyObject * Vector_CreatePyObject_cb(PyObject *cb_user, int vec_num, uchar cb_type, uchar cb_subtype)
static struct PyModuleDef module