39 "Class hierarchy: :class:`Interface1D` > :class:`Stroke`\n"
41 "Class to define a stroke. A stroke is made of a set of 2D vertices\n"
42 "(:class:`StrokeVertex`), regularly spaced out. This set of vertices\n"
43 "defines the stroke's backbone geometry. Each of these stroke vertices\n"
44 "defines the stroke's shape and appearance at this vertex position.\n"
46 ".. method:: Stroke()\n"
49 " Creates a :class:`Stroke` using the default constructor or copy constructor\n");
53 static const char *kwlist[] = {
"brother",
nullptr};
54 PyObject *brother =
nullptr;
56 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"|O!", (
char **)kwlist, &
Stroke_Type, &brother)) {
66 self->py_if1D.borrowed =
false;
78 return self->s->strokeVerticesSize();
87 PyErr_Format(PyExc_IndexError,
"Stroke[index]: index %d out of range", keynum);
95 Stroke_compute_sampling_doc,
96 ".. method:: compute_sampling(n)\n"
98 " Compute the sampling needed to get N vertices. If the\n"
99 " specified number of vertices is less than the actual number of\n"
100 " vertices, the actual sampling value is returned. (To remove Vertices,\n"
101 " use the RemoveVertex() method of this class.)\n"
103 " :arg n: The number of stroke vertices we eventually want\n"
106 " :return: The sampling that must be used in the Resample(float)\n"
112 static const char *kwlist[] = {
"n",
nullptr};
115 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"i", (
char **)kwlist, &i)) {
118 return PyFloat_FromDouble(
self->s->ComputeSampling(i));
124 ".. method:: resample(n)\n"
125 " resample(sampling)\n"
127 " Resamples the stroke so using one of two methods with the goal\n"
128 " of creating a stroke with fewer points and the same shape.\n"
130 " :arg n: Resamples the stroke so that it eventually has N points. That means\n"
131 " it is going to add N-vertices_size, where vertices_size is the\n"
132 " number of points we already have. If vertices_size >= N, no\n"
133 " resampling is done.\n"
135 " :arg sampling: Resamples the stroke with a given sampling value. If the\n"
136 " sampling is smaller than the actual sampling value, no resampling is done.\n"
137 " :type sampling: float");
141 static const char *kwlist_1[] = {
"n",
nullptr};
142 static const char *kwlist_2[] = {
"sampling",
nullptr};
146 if (PyArg_ParseTupleAndKeywords(args, kwds,
"i", (
char **)kwlist_1, &i)) {
147 if (
self->s->Resample(i) < 0) {
148 PyErr_SetString(PyExc_RuntimeError,
"Stroke resampling (by vertex count) failed");
152 else if ((
void)PyErr_Clear(),
153 PyArg_ParseTupleAndKeywords(args, kwds,
"f", (
char **)kwlist_2, &f))
155 if (
self->s->Resample(f) < 0) {
156 PyErr_SetString(PyExc_RuntimeError,
"Stroke resampling (by vertex interval) failed");
161 PyErr_SetString(PyExc_TypeError,
"invalid argument");
169 Stroke_insert_vertex_doc,
170 ".. method:: insert_vertex(vertex, next)\n"
172 " Inserts the StrokeVertex given as argument into the Stroke before the\n"
173 " point specified by next. The length and curvilinear abscissa are\n"
174 " updated consequently.\n"
176 " :arg vertex: The StrokeVertex to insert in the Stroke.\n"
177 " :type vertex: :class:`StrokeVertex`\n"
178 " :arg next: A StrokeVertexIterator pointing to the StrokeVertex\n"
179 " before which vertex must be inserted.\n"
180 " :type next: :class:`StrokeVertexIterator`");
184 static const char *kwlist[] = {
"vertex",
"next",
nullptr};
185 PyObject *py_sv =
nullptr, *py_sv_it =
nullptr;
187 if (!PyArg_ParseTupleAndKeywords(args,
204 self->s->InsertVertex(sv, sv_it);
210 Stroke_remove_vertex_doc,
211 ".. method:: remove_vertex(vertex)\n"
213 " Removes the StrokeVertex given as argument from the Stroke. The length\n"
214 " and curvilinear abscissa are updated consequently.\n"
216 " :arg vertex: the StrokeVertex to remove from the Stroke.\n"
217 " :type vertex: :class:`StrokeVertex`");
221 static const char *kwlist[] = {
"vertex",
nullptr};
222 PyObject *py_sv =
nullptr;
224 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"O!", (
char **)kwlist, &
StrokeVertex_Type, &py_sv))
232 PyErr_SetString(PyExc_TypeError,
"invalid argument");
240 Stroke_remove_all_vertices_doc,
241 ".. method:: remove_all_vertices()\n"
243 " Removes all vertices from the Stroke.");
247 self->s->RemoveAllVertices();
253 Stroke_update_length_doc,
254 ".. method:: update_length()\n"
256 " Updates the 2D length of the Stroke.");
260 self->s->UpdateLength();
266 Stroke_stroke_vertices_begin_doc,
267 ".. method:: stroke_vertices_begin(t=0.0)\n"
269 " Returns a StrokeVertexIterator pointing on the first StrokeVertex of\n"
270 " the Stroke. One can specify a sampling value to re-sample the Stroke\n"
271 " on the fly if needed.\n"
273 " :arg t: The resampling value with which we want our Stroke to be\n"
274 " resampled. If 0 is specified, no resampling is done.\n"
276 " :return: A StrokeVertexIterator pointing on the first StrokeVertex.\n"
277 " :rtype: :class:`StrokeVertexIterator`");
281 static const char *kwlist[] = {
"t",
nullptr};
284 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"|f", (
char **)kwlist, &f)) {
293 Stroke_stroke_vertices_end_doc,
294 ".. method:: stroke_vertices_end()\n"
296 " Returns a StrokeVertexIterator pointing after the last StrokeVertex\n"
299 " :return: A StrokeVertexIterator pointing after the last StrokeVertex.\n"
300 " :rtype: :class:`StrokeVertexIterator`");
311 ".. method:: __reversed__()\n"
313 " Returns a StrokeVertexIterator iterating over the vertices of the Stroke\n"
314 " in the reversed order (from the last to the first).\n"
316 " :return: A StrokeVertexIterator pointing after the last StrokeVertex.\n"
317 " :rtype: :class:`StrokeVertexIterator`");
327 Stroke_stroke_vertices_size_doc,
328 ".. method:: stroke_vertices_size()\n"
330 " Returns the number of StrokeVertex constituting the Stroke.\n"
332 " :return: The number of stroke vertices.\n"
337 return PyLong_FromLong(
self->s->strokeVerticesSize());
343 METH_VARARGS | METH_KEYWORDS,
344 Stroke_compute_sampling_doc},
345 {
"resample", (PyCFunction)
Stroke_resample, METH_VARARGS | METH_KEYWORDS, Stroke_resample_doc},
346 {
"remove_all_vertices",
349 Stroke_remove_all_vertices_doc},
352 METH_VARARGS | METH_KEYWORDS,
353 Stroke_remove_vertex_doc},
356 METH_VARARGS | METH_KEYWORDS,
357 Stroke_insert_vertex_doc},
359 {
"stroke_vertices_begin",
361 METH_VARARGS | METH_KEYWORDS,
362 Stroke_stroke_vertices_begin_doc},
363 {
"stroke_vertices_end",
366 Stroke_stroke_vertices_end_doc},
367 {
"__reversed__", (PyCFunction)
Stroke_reversed, METH_NOARGS, Stroke_reversed_doc},
368 {
"stroke_vertices_size",
371 Stroke_stroke_vertices_size_doc},
372 {
nullptr,
nullptr, 0,
nullptr},
379 Stroke_medium_type_doc,
380 "The MediumType used for this Stroke.\n"
382 ":type: :class:`MediumType`");
392 PyErr_SetString(PyExc_TypeError,
"value must be a MediumType");
401 Stroke_texture_id_doc,
402 "The ID of the texture used to simulate th marks system for this Stroke.\n"
408 return PyLong_FromLong(
self->s->getTextureId());
413 uint i = PyLong_AsUnsignedLong(value);
414 if (PyErr_Occurred()) {
417 self->s->setTextureId(i);
424 "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"
451 return PyFloat_FromDouble(
self->s->getLength2D());
457 if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
459 PyErr_SetString(PyExc_TypeError,
"value must be a number");
462 self->s->setLength(scalar);
469 "The Id of this Stroke.\n"
471 ":type: :class:`Id`");
482 PyErr_SetString(PyExc_TypeError,
"value must be an Id");
493 Stroke_medium_type_doc,
498 Stroke_texture_id_doc,
504 Stroke_length_2d_doc,
507 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
526 PyVarObject_HEAD_INIT(
nullptr, 0)
545 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 *)