Blender  V2.93
BPy_CalligraphicShader.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include "BPy_CalligraphicShader.h"
22 
23 #include "../../stroke/AdvancedStrokeShaders.h"
24 #include "../BPy_Convert.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 using namespace Freestyle;
31 
33 
34 //------------------------INSTANCE METHODS ----------------------------------
35 
37  "Class hierarchy: :class:`freestyle.types.StrokeShader` > :class:`CalligraphicShader`\n"
38  "\n"
39  "[Thickness Shader]\n"
40  "\n"
41  ".. method:: __init__(thickness_min, thickness_max, orientation, clamp)\n"
42  "\n"
43  " Builds a CalligraphicShader object.\n"
44  "\n"
45  " :arg thickness_min: The minimum thickness in the direction\n"
46  " perpendicular to the main direction.\n"
47  " :type thickness_min: float\n"
48  " :arg thickness_max: The maximum thickness in the main direction.\n"
49  " :type thickness_max: float\n"
50  " :arg orientation: The 2D vector giving the main direction.\n"
51  " :type orientation: :class:`mathutils.Vector`\n"
52  " :arg clamp: If true, the strokes are drawn in black when the stroke\n"
53  " direction is between -90 and 90 degrees with respect to the main\n"
54  " direction and drawn in white otherwise. If false, the strokes\n"
55  " are always drawn in black.\n"
56  " :type clamp: bool\n"
57  "\n"
58  ".. method:: shade(stroke)\n"
59  "\n"
60  " Assigns thicknesses to the stroke vertices so that the stroke looks\n"
61  " like made with a calligraphic tool, i.e. the stroke will be the\n"
62  " thickest in a main direction, and the thinnest in the direction\n"
63  " perpendicular to this one, and an interpolation in between.\n"
64  "\n"
65  " :arg stroke: A Stroke object.\n"
66  " :type stroke: :class:`freestyle.types.Stroke`\n";
67 
69  PyObject *args,
70  PyObject *kwds)
71 {
72  static const char *kwlist[] = {
73  "thickness_min", "thickness_max", "orientation", "clamp", nullptr};
74  double d1, d2;
75  float f3[2];
76  PyObject *obj4 = nullptr;
77 
78  if (!PyArg_ParseTupleAndKeywords(
79  args, kwds, "ddO&O!", (char **)kwlist, &d1, &d2, convert_v2, f3, &PyBool_Type, &obj4)) {
80  return -1;
81  }
82  Vec2f v(f3[0], f3[1]);
83  self->py_ss.ss = new CalligraphicShader(d1, d2, v, bool_from_PyBool(obj4));
84  return 0;
85 }
86 
87 /*-----------------------BPy_CalligraphicShader type definition ------------------------------*/
88 
89 PyTypeObject CalligraphicShader_Type = {
90  PyVarObject_HEAD_INIT(nullptr, 0) "CalligraphicShader", /* tp_name */
91  sizeof(BPy_CalligraphicShader), /* tp_basicsize */
92  0, /* tp_itemsize */
93  nullptr, /* tp_dealloc */
94  0, /* tp_vectorcall_offset */
95  nullptr, /* tp_getattr */
96  nullptr, /* tp_setattr */
97  nullptr, /* tp_reserved */
98  nullptr, /* tp_repr */
99  nullptr, /* tp_as_number */
100  nullptr, /* tp_as_sequence */
101  nullptr, /* tp_as_mapping */
102  nullptr, /* tp_hash */
103  nullptr, /* tp_call */
104  nullptr, /* tp_str */
105  nullptr, /* tp_getattro */
106  nullptr, /* tp_setattro */
107  nullptr, /* tp_as_buffer */
108  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
109  CalligraphicShader___doc__, /* tp_doc */
110  nullptr, /* tp_traverse */
111  nullptr, /* tp_clear */
112  nullptr, /* tp_richcompare */
113  0, /* tp_weaklistoffset */
114  nullptr, /* tp_iter */
115  nullptr, /* tp_iternext */
116  nullptr, /* tp_methods */
117  nullptr, /* tp_members */
118  nullptr, /* tp_getset */
119  &StrokeShader_Type, /* tp_base */
120  nullptr, /* tp_dict */
121  nullptr, /* tp_descr_get */
122  nullptr, /* tp_descr_set */
123  0, /* tp_dictoffset */
124  (initproc)CalligraphicShader___init__, /* tp_init */
125  nullptr, /* tp_alloc */
126  nullptr, /* tp_new */
127 };
128 
130 
131 #ifdef __cplusplus
132 }
133 #endif
static char CalligraphicShader___doc__[]
static int CalligraphicShader___init__(BPy_CalligraphicShader *self, PyObject *args, PyObject *kwds)
PyTypeObject CalligraphicShader_Type
bool bool_from_PyBool(PyObject *b)
int convert_v2(PyObject *obj, void *v)
PyTypeObject StrokeShader_Type
ATTR_WARN_UNUSED_RESULT const BMVert * v
inherits from class Rep
Definition: AppCanvas.cpp:32