@@ -42,10 +42,10 @@ def _fn_name(): return sys._getframe(1).f_code.co_name
42
42
from matplotlib .transforms import Bbox
43
43
44
44
45
- if hasattr (cairo .ImageSurface , 'create_for_array' ):
46
- HAVE_CAIRO_NUMPY = True
47
- else :
48
- HAVE_CAIRO_NUMPY = False
45
+ # if hasattr (cairo.ImageSurface, 'create_for_array'):
46
+ # HAVE_CAIRO_NUMPY = True
47
+ # else:
48
+ # HAVE_CAIRO_NUMPY = False
49
49
50
50
51
51
_debug = False
@@ -134,15 +134,15 @@ def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, rotation):
134
134
# FIXME
135
135
# to get a proper arc of width/height you can use translate() and
136
136
# scale(), see draw_arc() manual page
137
-
137
+
138
138
#radius = (height + width) / 4
139
139
ctx = gc .ctx
140
140
ctx .save ()
141
141
ctx .rotate (rotation )
142
142
ctx .scale (width / 2.0 , height / 2.0 )
143
143
ctx .arc (0.0 , 0.0 , 1.0 , 0.0 , 2 * numx .pi )
144
144
ctx .restore ()
145
-
145
+
146
146
#ctx.new_path()
147
147
#ctx.arc (x, self.height - y, radius,
148
148
# angle1 * numx.pi/180.0, angle2 * numx.pi/180.0)
@@ -153,15 +153,15 @@ def draw_image(self, x, y, im, bbox):
153
153
# bbox - not currently used
154
154
if _debug : print '%s.%s()' % (self .__class__ .__name__ , _fn_name ())
155
155
156
- if numx .which [0 ] == "numarray" :
157
- warnings .warn ("draw_image() currently works for numpy, but not "
158
- "numarray" )
159
- return
156
+ # if numx.which[0] == "numarray":
157
+ # warnings.warn("draw_image() currently works for numpy, but not "
158
+ # "numarray")
159
+ # return
160
160
161
- if not HAVE_CAIRO_NUMPY :
162
- warnings .warn ("cairo with Numeric support is required for "
163
- "draw_image()" )
164
- return
161
+ # if not HAVE_CAIRO_NUMPY:
162
+ # warnings.warn("cairo with Numeric support is required for "
163
+ # "draw_image()")
164
+ # return
165
165
166
166
im .flipud_out ()
167
167
@@ -171,7 +171,9 @@ def draw_image(self, x, y, im, bbox):
171
171
172
172
# function does not pass a 'gc' so use renderer.ctx
173
173
ctx = self .ctx
174
- surface = cairo .ImageSurface .create_for_array (X )
174
+ #surface = cairo.ImageSurface.create_for_array (X)
175
+ surface = cairo .ImageSurface .create_for_data (X , cairo .FORMAT_ARGB32 ,
176
+ rows , cols , rows * 4 )
175
177
ctx .set_source_surface (surface , x , y )
176
178
ctx .paint ()
177
179
@@ -318,17 +320,17 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False):
318
320
319
321
def _draw_mathtext (self , gc , x , y , s , prop , angle ):
320
322
if _debug : print '%s.%s()' % (self .__class__ .__name__ , _fn_name ())
321
- # mathtext using the gtk/gdk method
323
+ # mathtext using the gtk/gdk method
322
324
323
- if numx .which [0 ] == "numarray" :
324
- warnings .warn ("_draw_mathtext() currently works for numpy, but "
325
- "not numarray" )
326
- return
325
+ # if numx.which[0] == "numarray":
326
+ # warnings.warn("_draw_mathtext() currently works for numpy, but "
327
+ # "not numarray")
328
+ # return
327
329
328
- if not HAVE_CAIRO_NUMPY :
329
- warnings .warn ("cairo with Numeric support is required for "
330
- "_draw_mathtext()" )
331
- return
330
+ # if not HAVE_CAIRO_NUMPY:
331
+ # warnings.warn("cairo with Numeric support is required for "
332
+ # "_draw_mathtext()")
333
+ # return
332
334
333
335
size = prop .get_size_in_points ()
334
336
width , height , fonts = math_parse_s_ft2font (
@@ -364,8 +366,10 @@ def _draw_mathtext(self, gc, x, y, s, prop, angle):
364
366
pa [:,:,2 ] = int (rgb [2 ]* 255 )
365
367
pa [:,:,3 ] = Xs
366
368
367
- # works for numpy pa, not a numarray pa
368
- surface = cairo .ImageSurface .create_for_array (pa )
369
+ ## works for numpy pa, not a numarray pa
370
+ #surface = cairo.ImageSurface.create_for_array (pa)
371
+ surface = cairo .ImageSurface .create_for_data (pa , cairo .FORMAT_ARGB32 ,
372
+ imw , imh , imw * 4 )
369
373
gc .ctx .set_source_surface (surface , x , y )
370
374
gc .ctx .paint ()
371
375
#gc.ctx.show_surface (surface, imw, imh)
0 commit comments