35 "Class hierarchy: :class:`Interface1D` > :class:`Stroke`\n"
37 "Class to define a stroke. A stroke is made of a set of 2D vertices\n"
38 "(:class:`StrokeVertex`), regularly spaced out. This set of vertices\n"
39 "defines the stroke's backbone geometry. Each of these stroke vertices\n"
40 "defines the stroke's shape and appearance at this vertex position.\n"
42 ".. method:: Stroke()\n"
45 " Creates a :class:`Stroke` using the default constructor or copy constructor\n");
48 static const char *kwlist[] = {
"brother",
nullptr};
49 PyObject *brother =
nullptr;
51 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"|O!", (
char **)kwlist, &
Stroke_Type, &brother)) {
61 self->py_if1D.borrowed =
false;
73 return self->s->strokeVerticesSize();
82 PyErr_Format(PyExc_IndexError,
"Stroke[index]: index %d out of range", keynum);
90 Stroke_compute_sampling_doc,
91 ".. method:: compute_sampling(n)\n"
93 " Compute the sampling needed to get N vertices. If the\n"
94 " specified number of vertices is less than the actual number of\n"
95 " vertices, the actual sampling value is returned. (To remove Vertices,\n"
96 " use the RemoveVertex() method of this class.)\n"
98 " :arg n: The number of stroke vertices we eventually want\n"
101 " :return: The sampling that must be used in the Resample(float)\n"
106 static const char *kwlist[] = {
"n",
nullptr};
109 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"i", (
char **)kwlist, &
i)) {
112 return PyFloat_FromDouble(
self->s->ComputeSampling(
i));
118 ".. method:: resample(n)\n"
119 " resample(sampling)\n"
121 " Resamples the stroke so using one of two methods with the goal\n"
122 " of creating a stroke with fewer points and the same shape.\n"
124 " :arg n: Resamples the stroke so that it eventually has N points. That means\n"
125 " it is going to add N-vertices_size, where vertices_size is the\n"
126 " number of points we already have. If vertices_size >= N, no\n"
127 " resampling is done.\n"
129 " :arg sampling: Resamples the stroke with a given sampling value. If the\n"
130 " sampling is smaller than the actual sampling value, no resampling is done.\n"
131 " :type sampling: float\n");
134 static const char *kwlist_1[] = {
"n",
nullptr};
135 static const char *kwlist_2[] = {
"sampling",
nullptr};
139 if (PyArg_ParseTupleAndKeywords(args, kwds,
"i", (
char **)kwlist_1, &
i)) {
140 if (
self->s->Resample(
i) < 0) {
141 PyErr_SetString(PyExc_RuntimeError,
"Stroke resampling (by vertex count) failed");
145 else if ((
void)PyErr_Clear(),
146 PyArg_ParseTupleAndKeywords(args, kwds,
"f", (
char **)kwlist_2, &f))
148 if (
self->s->Resample(f) < 0) {
149 PyErr_SetString(PyExc_RuntimeError,
"Stroke resampling (by vertex interval) failed");
154 PyErr_SetString(PyExc_TypeError,
"invalid argument");
162 Stroke_insert_vertex_doc,
163 ".. method:: insert_vertex(vertex, next)\n"
165 " Inserts the StrokeVertex given as argument into the Stroke before the\n"
166 " point specified by next. The length and curvilinear abscissa are\n"
167 " updated consequently.\n"
169 " :arg vertex: The StrokeVertex to insert in the Stroke.\n"
170 " :type vertex: :class:`StrokeVertex`\n"
171 " :arg next: A StrokeVertexIterator pointing to the StrokeVertex\n"
172 " before which vertex must be inserted.\n"
173 " :type next: :class:`StrokeVertexIterator`\n");
176 static const char *kwlist[] = {
"vertex",
"next",
nullptr};
177 PyObject *py_sv =
nullptr, *py_sv_it =
nullptr;
179 if (!PyArg_ParseTupleAndKeywords(args,
196 self->s->InsertVertex(sv, sv_it);
202 Stroke_remove_vertex_doc,
203 ".. method:: remove_vertex(vertex)\n"
205 " Removes the StrokeVertex given as argument from the Stroke. The length\n"
206 " and curvilinear abscissa are updated consequently.\n"
208 " :arg vertex: the StrokeVertex to remove from the Stroke.\n"
209 " :type vertex: :class:`StrokeVertex`\n");
212 static const char *kwlist[] = {
"vertex",
nullptr};
213 PyObject *py_sv =
nullptr;
215 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"O!", (
char **)kwlist, &
StrokeVertex_Type, &py_sv))
223 PyErr_SetString(PyExc_TypeError,
"invalid argument");
231 Stroke_remove_all_vertices_doc,
232 ".. method:: remove_all_vertices()\n"
234 " Removes all vertices from the Stroke.\n");
237 self->s->RemoveAllVertices();
243 Stroke_update_length_doc,
244 ".. method:: update_length()\n"
246 " Updates the 2D length of the Stroke.\n");
249 self->s->UpdateLength();
255 Stroke_stroke_vertices_begin_doc,
256 ".. method:: stroke_vertices_begin(t=0.0)\n"
258 " Returns a StrokeVertexIterator pointing on the first StrokeVertex of\n"
259 " the Stroke. One can specify a sampling value to re-sample the Stroke\n"
260 " on the fly if needed.\n"
262 " :arg t: The resampling value with which we want our Stroke to be\n"
263 " resampled. If 0 is specified, no resampling is done.\n"
265 " :return: A StrokeVertexIterator pointing on the first StrokeVertex.\n"
266 " :rtype: :class:`StrokeVertexIterator`\n");
269 static const char *kwlist[] = {
"t",
nullptr};
272 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"|f", (
char **)kwlist, &f)) {
281 Stroke_stroke_vertices_end_doc,
282 ".. method:: stroke_vertices_end()\n"
284 " Returns a StrokeVertexIterator pointing after the last StrokeVertex\n"
287 " :return: A StrokeVertexIterator pointing after the last StrokeVertex.\n"
288 " :rtype: :class:`StrokeVertexIterator`\n");
298 ".. method:: __reversed__()\n"
300 " Returns a StrokeVertexIterator iterating over the vertices of the Stroke\n"
301 " in the reversed order (from the last to the first).\n"
303 " :return: A StrokeVertexIterator pointing after the last StrokeVertex.\n"
304 " :rtype: :class:`StrokeVertexIterator`\n");
313 Stroke_stroke_vertices_size_doc,
314 ".. method:: stroke_vertices_size()\n"
316 " Returns the number of StrokeVertex constituting the Stroke.\n"
318 " :return: The number of stroke vertices.\n"
322 return PyLong_FromLong(
self->s->strokeVerticesSize());
327# pragma clang diagnostic push
328# pragma clang diagnostic ignored "-Wcast-function-type"
330# pragma GCC diagnostic push
331# pragma GCC diagnostic ignored "-Wcast-function-type"
338 METH_VARARGS | METH_KEYWORDS,
339 Stroke_compute_sampling_doc},
340 {
"resample", (PyCFunction)
Stroke_resample, METH_VARARGS | METH_KEYWORDS, Stroke_resample_doc},
341 {
"remove_all_vertices",
344 Stroke_remove_all_vertices_doc},
347 METH_VARARGS | METH_KEYWORDS,
348 Stroke_remove_vertex_doc},
351 METH_VARARGS | METH_KEYWORDS,
352 Stroke_insert_vertex_doc},
354 {
"stroke_vertices_begin",
356 METH_VARARGS | METH_KEYWORDS,
357 Stroke_stroke_vertices_begin_doc},
358 {
"stroke_vertices_end",
361 Stroke_stroke_vertices_end_doc},
362 {
"__reversed__", (PyCFunction)
Stroke_reversed, METH_NOARGS, Stroke_reversed_doc},
363 {
"stroke_vertices_size",
366 Stroke_stroke_vertices_size_doc},
367 {
nullptr,
nullptr, 0,
nullptr},
372# pragma clang diagnostic pop
374# pragma GCC diagnostic pop
382 Stroke_medium_type_doc,
383 "The MediumType used for this Stroke.\n"
385 ":type: :class:`MediumType`\n");
394 PyErr_SetString(PyExc_TypeError,
"value must be a MediumType");
403 Stroke_texture_id_doc,
404 "The ID of the texture used to simulate th marks system for this Stroke.\n"
409 return PyLong_FromLong(
self->s->getTextureId());
414 uint i = PyLong_AsUnsignedLong(value);
415 if (PyErr_Occurred()) {
418 self->s->setTextureId(
i);
425 "True if this Stroke uses a texture with tips, and false otherwise.\n"
435 if (!PyBool_Check(value)) {
444 Stroke_length_2d_doc,
445 "The 2D length of the Stroke.\n"
450 return PyFloat_FromDouble(
self->s->getLength2D());
456 if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
458 PyErr_SetString(PyExc_TypeError,
"value must be a number");
461 self->s->setLength(scalar);
468 "The Id of this Stroke.\n"
470 ":type: :class:`Id`\n");
480 PyErr_SetString(PyExc_TypeError,
"value must be an Id");
491 Stroke_medium_type_doc,
496 Stroke_texture_id_doc,
502 Stroke_length_2d_doc,
505 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
524 PyVarObject_HEAD_INIT(
nullptr, 0)
543 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
PyObject * BPy_StrokeVertexIterator_from_StrokeVertexIterator(StrokeInternal::StrokeVertexIterator &sv_it, bool reversed)
PyObject * BPy_Id_from_Id(Id &id)
bool bool_from_PyBool(PyObject *b)
PyObject * BPy_StrokeVertex_from_StrokeVertex(StrokeVertex &sv)
PyObject * BPy_MediumType_from_MediumType(Stroke::MediumType n)
Stroke::MediumType MediumType_from_BPy_MediumType(PyObject *obj)
PyObject * PyBool_from_bool(bool b)
PyTypeObject Interface1D_Type
#define BPy_MediumType_Check(v)
PyTypeObject StrokeVertexIterator_Type
PyTypeObject StrokeVertex_Type
static PyObject * Stroke_remove_vertex(BPy_Stroke *self, PyObject *args, PyObject *kwds)
static int Stroke_medium_type_set(BPy_Stroke *self, PyObject *value, void *)
static PyObject * Stroke_update_length(BPy_Stroke *self)
static Py_ssize_t Stroke_sq_length(BPy_Stroke *self)
static PyObject * Stroke_texture_id_get(BPy_Stroke *self, void *)
static PyObject * Stroke_iter(PyObject *self)
static PyObject * Stroke_remove_all_vertices(BPy_Stroke *self)
static PyObject * Stroke_resample(BPy_Stroke *self, PyObject *args, PyObject *kwds)
static int Stroke_length_2d_set(BPy_Stroke *self, PyObject *value, void *)
static PyObject * Stroke_stroke_vertices_end(BPy_Stroke *self)
static PyObject * Stroke_medium_type_get(BPy_Stroke *self, void *)
static PySequenceMethods BPy_Stroke_as_sequence
static PyObject * Stroke_stroke_vertices_begin(BPy_Stroke *self, PyObject *args, PyObject *kwds)
static PyObject * Stroke_insert_vertex(BPy_Stroke *self, PyObject *args, PyObject *kwds)
static PyObject * Stroke_length_2d_get(BPy_Stroke *self, void *)
static PyMethodDef BPy_Stroke_methods[]
static int Stroke_id_set(BPy_Stroke *self, PyObject *value, void *)
static int Stroke_tips_set(BPy_Stroke *self, PyObject *value, void *)
PyDoc_STRVAR(Stroke_doc, "Class hierarchy: :class:`Interface1D` > :class:`Stroke`\n" "\n" "Class to define a stroke. A stroke is made of a set of 2D vertices\n" "(:class:`StrokeVertex`), regularly spaced out. This set of vertices\n" "defines the stroke's backbone geometry. Each of these stroke vertices\n" "defines the stroke's shape and appearance at this vertex position.\n" "\n" ".. method:: Stroke()\n" " Stroke(brother)\n" "\n" " Creates a :class:`Stroke` using the default constructor or copy constructor\n")
static PyObject * Stroke_tips_get(BPy_Stroke *self, void *)
static PyObject * Stroke_reversed(BPy_Stroke *self)
static int Stroke_texture_id_set(BPy_Stroke *self, PyObject *value, void *)
static PyObject * Stroke_stroke_vertices_size(BPy_Stroke *self)
static PyObject * Stroke_compute_sampling(BPy_Stroke *self, PyObject *args, PyObject *kwds)
static int Stroke_init(BPy_Stroke *self, PyObject *args, PyObject *kwds)
static PyGetSetDef BPy_Stroke_getseters[]
static PyObject * Stroke_sq_item(BPy_Stroke *self, Py_ssize_t keynum)
static PyObject * Stroke_id_get(BPy_Stroke *self, void *)