Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 852e4e3

Browse files
author
Steve Chaplin
committed
CS
svn path=/trunk/matplotlib/; revision=2982
1 parent e333c78 commit 852e4e3

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2007-01-14 backend_cairo.py: update draw_arc() so that
2+
examples/arctest.py looks correct - SC
3+
14
2007-01-12 backend_cairo.py: enable clipping. Update draw_image() so that
25
examples/contour_demo.py looks correct - SC
36

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def close_group(self, s):
3434
pass
3535

3636

37-
def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, rotation):
37+
def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2,
38+
rotation):
3839
"""
3940
Draw an arc using GraphicsContext instance gcEdge, centered at x,y,
4041
with width and height and angles from 0.0 to 360.0

lib/matplotlib/backends/backend_cairo.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,24 +128,22 @@ def _fill_and_stroke (self, ctx, fill_c):
128128
#_.ctx.restore() # revert to the default attributes
129129

130130

131-
def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, rotation):
131+
def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2,
132+
rotation):
132133
if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name())
133-
# draws circular arcs where width=height
134+
# this implementation draws circular arcs where width=height
134135
# FIXME
135136
# to get a proper arc of width/height you can use translate() and
136-
# scale(), see draw_arc() manual page
137+
# scale(), see cairo_arc() manual page
137138

138-
#radius = (height + width) / 4
139139
ctx = gc.ctx
140140
ctx.save()
141+
ctx.new_path() # prevent cairo_arc() adding to current path
141142
ctx.rotate(rotation)
142-
ctx.scale(width / 2.0, height / 2.0)
143-
ctx.arc(0.0, 0.0, 1.0, 0.0, 2*numx.pi)
143+
radius = (height + width) / 4
144+
ctx.arc (x, self.height - y, radius,
145+
angle1 * numx.pi/180.0, angle2 * numx.pi/180.0)
144146
ctx.restore()
145-
146-
#ctx.new_path()
147-
#ctx.arc (x, self.height - y, radius,
148-
# angle1 * numx.pi/180.0, angle2 * numx.pi/180.0)
149147
self._fill_and_stroke (ctx, rgbFace)
150148

151149

lib/matplotlib/backends/backend_template.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
matplotlib/backends/__init__.py
3333
matplotlib/__init__.py
3434
matplotlib/_pylab_helpers.py
35-
35+
3636
Naming Conventions
3737
3838
* classes Upper or MixedUpperCase
@@ -62,15 +62,16 @@ class RendererTemplate(RendererBase):
6262
writing a new backend. Refer to backend_bases.RendererBase for
6363
documentation of the classes methods.
6464
"""
65-
def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, rotation):
65+
def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2,
66+
rotation):
6667
pass
67-
68+
6869
def draw_image(self, x, y, im, bbox):
6970
pass
70-
71+
7172
def draw_line(self, gc, x1, y1, x2, y2):
7273
pass
73-
74+
7475
def draw_lines(self, gc, x, y):
7576
pass
7677

@@ -83,18 +84,18 @@ def draw_polygon(self, gcEdge, rgbFace, points):
8384
def draw_rectangle(self, gcEdge, rgbFace, x, y, width, height):
8485
pass
8586

86-
def draw_text(self, gc, x, y, s, prop, angle, ismath=False):
87+
def draw_text(self, gc, x, y, s, prop, angle, ismath=False):
8788
pass
88-
89+
8990
def flipy(self):
9091
return True
91-
92+
9293
def get_canvas_width_height(self):
9394
return 100, 100
9495

9596
def get_text_width_height(self, s, prop, ismath):
9697
return 1, 1
97-
98+
9899
def new_gc(self):
99100
return GraphicsContextTemplate()
100101

@@ -129,10 +130,10 @@ class GraphicsContextTemplate(GraphicsContextBase):
129130
"""
130131
pass
131132

132-
133-
133+
134+
134135
########################################################################
135-
#
136+
#
136137
# The following functions and classes are for pylab and implement
137138
# window/figure managers, etc...
138139
#
@@ -196,7 +197,7 @@ def draw(self):
196197
"""
197198
renderer = RendererTemplate()
198199
self.figure.draw(renderer)
199-
200+
200201
def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
201202
orientation='portrait', **kwargs):
202203
"""
@@ -221,7 +222,7 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
221222
# set the new parameters
222223
self.figure.dpi.set(dpi)
223224
self.figure.set_facecolor(facecolor)
224-
self.figure.set_edgecolor(edgecolor)
225+
self.figure.set_edgecolor(edgecolor)
225226

226227
renderer = RendererTemplate()
227228
self.figure.draw(renderer)
@@ -233,8 +234,8 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
233234
#self.figure.set_edgecolor(origedgecolor)
234235
# redraw the screen if necessary
235236
#self.draw()
236-
237-
237+
238+
238239
class FigureManagerTemplate(FigureManagerBase):
239240
"""
240241
Wrap everything up into a window for the pylab interface
@@ -244,9 +245,9 @@ class FigureManagerTemplate(FigureManagerBase):
244245
pass
245246

246247
########################################################################
247-
#
248+
#
248249
# Now just provide the standard names that backend.__init__ is expecting
249-
#
250+
#
250251
########################################################################
251252

252253

0 commit comments

Comments
 (0)