@@ -159,7 +159,26 @@ class Normal(AbstractPathEffect):
159
159
The Normal PathEffect's sole purpose is to draw the original artist with
160
160
no special path effect.
161
161
"""
162
- pass
162
+
163
+
164
+ def _make_with_effect (cls ):
165
+ """
166
+ Generate a PathEffect combining the effect of *cls* and a normal draw.
167
+ """
168
+
169
+ class withEffect (cls ):
170
+ def draw_path (self , renderer , gc , tpath , affine , rgbFace ):
171
+ super ().draw_path (renderer , gc , tpath , affine , rgbFace )
172
+ renderer .draw_path (gc , tpath , affine , rgbFace )
173
+
174
+ withEffect .__name__ = f"with{ cls .__name__ } "
175
+ withEffect .__doc__ = f"""
176
+ Adds a `.{ cls .__name__ } ` and then draws the original Artist to avoid
177
+ needing to call `.Normal`.
178
+ """
179
+ # Docstring inheritance doesn't work for locally-defined subclasses.
180
+ withEffect .draw_path .__doc__ = cls .draw_path .__doc__
181
+ return withEffect
163
182
164
183
165
184
class Stroke (AbstractPathEffect ):
@@ -185,15 +204,7 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
185
204
gc0 .restore ()
186
205
187
206
188
- class withStroke (Stroke ):
189
- """
190
- Adds a simple :class:`Stroke` and then draws the
191
- original Artist to avoid needing to call :class:`Normal`.
192
-
193
- """
194
- def draw_path (self , renderer , gc , tpath , affine , rgbFace ):
195
- Stroke .draw_path (self , renderer , gc , tpath , affine , rgbFace )
196
- renderer .draw_path (gc , tpath , affine , rgbFace )
207
+ withStroke = _make_with_effect (Stroke )
197
208
198
209
199
210
class SimplePatchShadow (AbstractPathEffect ):
@@ -262,15 +273,7 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
262
273
gc0 .restore ()
263
274
264
275
265
- class withSimplePatchShadow (SimplePatchShadow ):
266
- """
267
- Adds a simple :class:`SimplePatchShadow` and then draws the
268
- original Artist to avoid needing to call :class:`Normal`.
269
-
270
- """
271
- def draw_path (self , renderer , gc , tpath , affine , rgbFace ):
272
- SimplePatchShadow .draw_path (self , renderer , gc , tpath , affine , rgbFace )
273
- renderer .draw_path (gc , tpath , affine , rgbFace )
276
+ withSimplePatchShadow = _make_with_effect (SimplePatchShadow )
274
277
275
278
276
279
class SimpleLineShadow (AbstractPathEffect ):
0 commit comments