3
3
==============================
4
4
:Author: Steve Chaplin and others
5
5
6
- This backend depends on `cairo <http://cairographics.org>`_, and either on
7
- cairocffi, or (Python 2 only) on pycairo.
6
+ This backend depends on cairocffi or pycairo.
8
7
"""
9
8
10
9
import six
36
35
"cairo>=1.4.0 is required" .format (cairo .version ))
37
36
backend_version = cairo .version
38
37
38
+ from matplotlib import cbook
39
39
from matplotlib .backend_bases import (
40
40
_Backend , FigureCanvasBase , FigureManagerBase , GraphicsContextBase ,
41
41
RendererBase )
42
+ from matplotlib .font_manager import ttfFontProperty
42
43
from matplotlib .mathtext import MathTextParser
43
44
from matplotlib .path import Path
44
45
from matplotlib .transforms import Affine2D
45
- from matplotlib .font_manager import ttfFontProperty
46
46
47
47
48
48
def _premultiplied_argb32_to_unmultiplied_rgba8888 (buf ):
@@ -94,7 +94,7 @@ def buffer_info(self):
94
94
_CAIRO_PATH_TYPE_SIZES [cairo .PATH_CLOSE_PATH ] = 1
95
95
96
96
97
- def _convert_paths_slow (ctx , paths , transforms , clip = None ):
97
+ def _append_paths_slow (ctx , paths , transforms , clip = None ):
98
98
for path , transform in zip (paths , transforms ):
99
99
for points , code in path .iter_segments (transform , clip = clip ):
100
100
if code == Path .MOVETO :
@@ -112,7 +112,7 @@ def _convert_paths_slow(ctx, paths, transforms, clip=None):
112
112
ctx .curve_to (* points )
113
113
114
114
115
- def _convert_paths_fast (ctx , paths , transforms , clip = None ):
115
+ def _append_paths_fast (ctx , paths , transforms , clip = None ):
116
116
# We directly convert to the internal representation used by cairo, for
117
117
# which ABI compatibility is guaranteed. The layout for each item is
118
118
# --CODE(4)-- -LENGTH(4)- ---------PAD(8)---------
@@ -160,11 +160,11 @@ def _convert_paths_fast(ctx, paths, transforms, clip=None):
160
160
cairo .cairo .cairo_append_path (ctx ._pointer , ptr )
161
161
162
162
163
- _convert_paths = _convert_paths_fast if HAS_CAIRO_CFFI else _convert_paths_slow
163
+ _append_paths = _append_paths_fast if HAS_CAIRO_CFFI else _append_paths_slow
164
164
165
165
166
- def _convert_path (ctx , path , transform , clip = None ):
167
- return _convert_paths (ctx , [path ], [transform ], clip )
166
+ def _append_path (ctx , path , transform , clip = None ):
167
+ return _append_paths (ctx , [path ], [transform ], clip )
168
168
169
169
170
170
class RendererCairo (RendererBase ):
@@ -226,6 +226,11 @@ def _fill_and_stroke(self, ctx, fill_c, alpha, alpha_overrides):
226
226
ctx .restore ()
227
227
ctx .stroke ()
228
228
229
+ @staticmethod
230
+ @cbook .deprecated ("3.0" )
231
+ def convert_path (ctx , path , transform , clip = None ):
232
+ _append_path (ctx , path , transform , clip )
233
+
229
234
def draw_path (self , gc , path , transform , rgbFace = None ):
230
235
ctx = gc .ctx
231
236
# Clip the path to the actual rendering extents if it isn't filled.
@@ -235,7 +240,7 @@ def draw_path(self, gc, path, transform, rgbFace=None):
235
240
transform = (transform
236
241
+ Affine2D ().scale (1 , - 1 ).translate (0 , self .height ))
237
242
ctx .new_path ()
238
- _convert_path (ctx , path , transform , clip )
243
+ _append_path (ctx , path , transform , clip )
239
244
self ._fill_and_stroke (
240
245
ctx , rgbFace , gc .get_alpha (), gc .get_forced_alpha ())
241
246
@@ -245,7 +250,7 @@ def draw_markers(self, gc, marker_path, marker_trans, path, transform,
245
250
246
251
ctx .new_path ()
247
252
# Create the path for the marker; it needs to be flipped here already!
248
- _convert_path (ctx , marker_path , marker_trans + Affine2D ().scale (1 , - 1 ))
253
+ _append_path (ctx , marker_path , marker_trans + Affine2D ().scale (1 , - 1 ))
249
254
marker_path = ctx .copy_path_flat ()
250
255
251
256
# Figure out whether the path has a fill
@@ -316,7 +321,7 @@ def _draw_paths():
316
321
gc .ctx .new_path ()
317
322
paths , transforms = zip (* grouped_draw )
318
323
grouped_draw .clear ()
319
- _convert_paths (gc .ctx , paths , transforms )
324
+ _append_paths (gc .ctx , paths , transforms )
320
325
self ._fill_and_stroke (
321
326
gc .ctx , rgb_fc , gc .get_alpha (), gc .get_forced_alpha ())
322
327
@@ -529,7 +534,7 @@ def set_clip_path(self, path):
529
534
ctx .new_path ()
530
535
affine = (affine
531
536
+ Affine2D ().scale (1 , - 1 ).translate (0 , self .renderer .height ))
532
- _convert_path (ctx , tpath , affine )
537
+ _append_path (ctx , tpath , affine )
533
538
ctx .clip ()
534
539
535
540
def set_dashes (self , offset , dashes ):
0 commit comments