@@ -77,15 +77,6 @@ def buffer_info(self):
77
77
_CAIRO_PATH_TYPE_SIZES [cairo .PATH_CLOSE_PATH ] = 1
78
78
79
79
80
- def _convert_path (ctx , path , transform , clip = None ):
81
- return _convert_paths (ctx , [path ], [transform ], clip )
82
-
83
-
84
- def _convert_paths (ctx , paths , transforms , clip = None ):
85
- return (_convert_paths_fast if HAS_CAIRO_CFFI else _convert_paths_slow )(
86
- ctx , paths , transforms , clip )
87
-
88
-
89
80
def _convert_paths_slow (ctx , paths , transforms , clip = None ):
90
81
for path , transform in zip (paths , transforms ):
91
82
for points , code in path .iter_segments (transform , clip = clip ):
@@ -106,7 +97,7 @@ def _convert_paths_slow(ctx, paths, transforms, clip=None):
106
97
107
98
def _convert_paths_fast (ctx , paths , transforms , clip = None ):
108
99
# We directly convert to the internal representation used by cairo, for
109
- # which ABI compatibility is guaranteed. The layout is for each item is
100
+ # which ABI compatibility is guaranteed. The layout for each item is
110
101
# --CODE(4)-- -LENGTH(4)- ---------PAD(8)---------
111
102
# ----------X(8)---------- ----------Y(8)----------
112
103
# with the size in bytes in parentheses, and (X, Y) repeated as many times
@@ -152,6 +143,13 @@ def _convert_paths_fast(ctx, paths, transforms, clip=None):
152
143
cairo .cairo .cairo_append_path (ctx ._pointer , ptr )
153
144
154
145
146
+ _convert_paths = _convert_paths_fast if HAS_CAIRO_CFFI else _convert_paths_slow
147
+
148
+
149
+ def _convert_path (ctx , path , transform , clip = None ):
150
+ return _convert_paths (ctx , [path ], [transform ], clip )
151
+
152
+
155
153
class RendererCairo (RendererBase ):
156
154
fontweights = {
157
155
100 : cairo .FONT_WEIGHT_NORMAL ,
@@ -230,8 +228,7 @@ def draw_markers(self, gc, marker_path, marker_trans, path, transform,
230
228
231
229
ctx .new_path ()
232
230
# Create the path for the marker; it needs to be flipped here already!
233
- _convert_path (
234
- ctx , marker_path , marker_trans + Affine2D ().scale (1 , - 1 ))
231
+ _convert_path (ctx , marker_path , marker_trans + Affine2D ().scale (1 , - 1 ))
235
232
marker_path = ctx .copy_path_flat ()
236
233
237
234
# Figure out whether the path has a fill
@@ -295,7 +292,7 @@ def _draw_paths():
295
292
for k , v in gc_vars .items ():
296
293
try :
297
294
getattr (gc , "set" + k )(v )
298
- except (AttributeError , TypeError ):
295
+ except (AttributeError , TypeError ) as e :
299
296
pass
300
297
gc .ctx .new_path ()
301
298
paths , transforms = zip (* grouped_draw )
@@ -309,8 +306,8 @@ def _draw_paths():
309
306
offsetTrans , facecolors , edgecolors , linewidths , linestyles ,
310
307
antialiaseds , urls , offset_position ):
311
308
path , transform = path_id
312
- transform = (Affine2D (transform .get_matrix ()). translate ( xo , yo )
313
- + Affine2D (). scale ( 1 , - 1 ). translate ( 0 , self . height ))
309
+ transform = (Affine2D (transform .get_matrix ())
310
+ . translate ( xo , yo - self . height ). scale ( 1 , - 1 ))
314
311
# rgb_fc could be a ndarray, for which equality is elementwise.
315
312
new_key = vars (gc0 ), tuple (rgb_fc ) if rgb_fc is not None else None
316
313
if new_key == reuse_key :
0 commit comments