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");
49 static const char *kwlist[] = {
"brother",
nullptr};
50 PyObject *brother =
nullptr;
52 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"|O!", (
char **)kwlist, &
Stroke_Type, &brother)) {
62 self->py_if1D.borrowed =
false;
74 return self->s->strokeVerticesSize();
83 PyErr_Format(PyExc_IndexError,
"Stroke[index]: index %d out of range", keynum);
91 Stroke_compute_sampling_doc,
92 ".. method:: compute_sampling(n)\n"
94 " Compute the sampling needed to get N vertices. If the\n"
95 " specified number of vertices is less than the actual number of\n"
96 " vertices, the actual sampling value is returned. (To remove Vertices,\n"
97 " use the RemoveVertex() method of this class.)\n"
99 " :arg n: The number of stroke vertices we eventually want\n"
102 " :return: The sampling that must be used in the Resample(float)\n"
108 static const char *kwlist[] = {
"n",
nullptr};
111 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"i", (
char **)kwlist, &
i)) {
114 return PyFloat_FromDouble(
self->s->ComputeSampling(
i));
120 ".. method:: resample(n)\n"
121 " resample(sampling)\n"
123 " Resamples the stroke so using one of two methods with the goal\n"
124 " of creating a stroke with fewer points and the same shape.\n"
126 " :arg n: Resamples the stroke so that it eventually has N points. That means\n"
127 " it is going to add N-vertices_size, where vertices_size is the\n"
128 " number of points we already have. If vertices_size >= N, no\n"
129 " resampling is done.\n"
131 " :arg sampling: Resamples the stroke with a given sampling value. If the\n"
132 " sampling is smaller than the actual sampling value, no resampling is done.\n"
133 " :type sampling: float");
137 static const char *kwlist_1[] = {
"n",
nullptr};
138 static const char *kwlist_2[] = {
"sampling",
nullptr};
142 if (PyArg_ParseTupleAndKeywords(args, kwds,
"i", (
char **)kwlist_1, &
i)) {
143 if (
self->s->Resample(
i) < 0) {
144 PyErr_SetString(PyExc_RuntimeError,
"Stroke resampling (by vertex count) failed");
148 else if ((
void)PyErr_Clear(),
149 PyArg_ParseTupleAndKeywords(args, kwds,
"f", (
char **)kwlist_2, &f))
151 if (
self->s->Resample(f) < 0) {
152 PyErr_SetString(PyExc_RuntimeError,
"Stroke resampling (by vertex interval) failed");
157 PyErr_SetString(PyExc_TypeError,
"invalid argument");
165 Stroke_insert_vertex_doc,
166 ".. method:: insert_vertex(vertex, next)\n"
168 " Inserts the StrokeVertex given as argument into the Stroke before the\n"
169 " point specified by next. The length and curvilinear abscissa are\n"
170 " updated consequently.\n"
172 " :arg vertex: The StrokeVertex to insert in the Stroke.\n"
173 " :type vertex: :class:`StrokeVertex`\n"
174 " :arg next: A StrokeVertexIterator pointing to the StrokeVertex\n"
175 " before which vertex must be inserted.\n"
176 " :type next: :class:`StrokeVertexIterator`");
180 static const char *kwlist[] = {
"vertex",
"next",
nullptr};
181 PyObject *py_sv =
nullptr, *py_sv_it =
nullptr;
183 if (!PyArg_ParseTupleAndKeywords(args,
200 self->s->InsertVertex(sv, sv_it);
206 Stroke_remove_vertex_doc,
207 ".. method:: remove_vertex(vertex)\n"
209 " Removes the StrokeVertex given as argument from the Stroke. The length\n"
210 " and curvilinear abscissa are updated consequently.\n"
212 " :arg vertex: the StrokeVertex to remove from the Stroke.\n"
213 " :type vertex: :class:`StrokeVertex`");
217 static const char *kwlist[] = {
"vertex",
nullptr};
218 PyObject *py_sv =
nullptr;
220 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"O!", (
char **)kwlist, &
StrokeVertex_Type, &py_sv))
228 PyErr_SetString(PyExc_TypeError,
"invalid argument");
236 Stroke_remove_all_vertices_doc,
237 ".. method:: remove_all_vertices()\n"
239 " Removes all vertices from the Stroke.");
243 self->s->RemoveAllVertices();
249 Stroke_update_length_doc,
250 ".. method:: update_length()\n"
252 " Updates the 2D length of the Stroke.");
256 self->s->UpdateLength();
262 Stroke_stroke_vertices_begin_doc,
263 ".. method:: stroke_vertices_begin(t=0.0)\n"
265 " Returns a StrokeVertexIterator pointing on the first StrokeVertex of\n"
266 " the Stroke. One can specify a sampling value to re-sample the Stroke\n"
267 " on the fly if needed.\n"
269 " :arg t: The resampling value with which we want our Stroke to be\n"
270 " resampled. If 0 is specified, no resampling is done.\n"
272 " :return: A StrokeVertexIterator pointing on the first StrokeVertex.\n"
273 " :rtype: :class:`StrokeVertexIterator`");
277 static const char *kwlist[] = {
"t",
nullptr};
280 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"|f", (
char **)kwlist, &f)) {
289 Stroke_stroke_vertices_end_doc,
290 ".. method:: stroke_vertices_end()\n"
292 " Returns a StrokeVertexIterator pointing after the last StrokeVertex\n"
295 " :return: A StrokeVertexIterator pointing after the last StrokeVertex.\n"
296 " :rtype: :class:`StrokeVertexIterator`");
307 ".. method:: __reversed__()\n"
309 " Returns a StrokeVertexIterator iterating over the vertices of the Stroke\n"
310 " in the reversed order (from the last to the first).\n"
312 " :return: A StrokeVertexIterator pointing after the last StrokeVertex.\n"
313 " :rtype: :class:`StrokeVertexIterator`");
323 Stroke_stroke_vertices_size_doc,
324 ".. method:: stroke_vertices_size()\n"
326 " Returns the number of StrokeVertex constituting the Stroke.\n"
328 " :return: The number of stroke vertices.\n"
333 return PyLong_FromLong(
self->s->strokeVerticesSize());
338# pragma clang diagnostic push
339# pragma clang diagnostic ignored "-Wcast-function-type"
341# pragma GCC diagnostic push
342# pragma GCC diagnostic ignored "-Wcast-function-type"
349 METH_VARARGS | METH_KEYWORDS,
350 Stroke_compute_sampling_doc},
351 {
"resample", (PyCFunction)
Stroke_resample, METH_VARARGS | METH_KEYWORDS, Stroke_resample_doc},
352 {
"remove_all_vertices",
355 Stroke_remove_all_vertices_doc},
358 METH_VARARGS | METH_KEYWORDS,
359 Stroke_remove_vertex_doc},
362 METH_VARARGS | METH_KEYWORDS,
363 Stroke_insert_vertex_doc},
365 {
"stroke_vertices_begin",
367 METH_VARARGS | METH_KEYWORDS,
368 Stroke_stroke_vertices_begin_doc},
369 {
"stroke_vertices_end",
372 Stroke_stroke_vertices_end_doc},
373 {
"__reversed__", (PyCFunction)
Stroke_reversed, METH_NOARGS, Stroke_reversed_doc},
374 {
"stroke_vertices_size",
377 Stroke_stroke_vertices_size_doc},
378 {
nullptr,
nullptr, 0,
nullptr},
383# pragma clang diagnostic pop
385# pragma GCC diagnostic pop
393 Stroke_medium_type_doc,
394 "The MediumType used for this Stroke.\n"
396 ":type: :class:`MediumType`");
406 PyErr_SetString(PyExc_TypeError,
"value must be a MediumType");
415 Stroke_texture_id_doc,
416 "The ID of the texture used to simulate th marks system for this Stroke.\n"
422 return PyLong_FromLong(
self->s->getTextureId());
427 uint i = PyLong_AsUnsignedLong(value);
428 if (PyErr_Occurred()) {
431 self->s->setTextureId(
i);
438 "True if this Stroke uses a texture with tips, and false otherwise.\n"
449 if (!PyBool_Check(value)) {
458 Stroke_length_2d_doc,
459 "The 2D length of the Stroke.\n"
465 return PyFloat_FromDouble(
self->s->getLength2D());
471 if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
473 PyErr_SetString(PyExc_TypeError,
"value must be a number");
476 self->s->setLength(scalar);
483 "The Id of this Stroke.\n"
485 ":type: :class:`Id`");
496 PyErr_SetString(PyExc_TypeError,
"value must be an Id");
507 Stroke_medium_type_doc,
512 Stroke_texture_id_doc,
518 Stroke_length_2d_doc,
521 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
540 PyVarObject_HEAD_INIT(
nullptr, 0)
559 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 *)