Skip to content

Commit f2176a3

Browse files
author
Steve Chaplin
committed
SC 25/10/2004
svn path=/trunk/matplotlib/; revision=613
1 parent 674f927 commit f2176a3

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

lib/matplotlib/backends/backend_gtk.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,30 @@ def set_drawing_area(self, da):
6363

6464
def get_color(self, rgb):
6565
"""
66-
RGB is a unit RGB tuple, return a gtk.gdk.Color
66+
Take an RGB (a unit RGB tuple) and return a allocated gtk.gdk.Color
6767
"""
68+
try:
69+
return self._cached[tuple(rgb)]
70+
except KeyError:
71+
if self._cmap is None:
72+
raise RuntimeError('First set the drawing area!')
6873

69-
try: return self._cached[tuple(rgb)]
70-
except KeyError: pass
71-
72-
if self._cmap is None:
73-
raise RuntimeError('First set the drawing area!')
74-
75-
#print 'rgb is', rgb
76-
r,g,b = rgb
77-
color = self._cmap.alloc_color(int(r*65025),int(g*65025),int(b*65025))
78-
self._cached[tuple(rgb)] = color
79-
return color
74+
r,g,b = rgb
75+
color = self._cmap.alloc_color(
76+
int(r*65025),int(g*65025),int(b*65025))
77+
self._cached[tuple(rgb)] = color
78+
return color
8079

8180
def get_rgb(self, color):
8281
"""
83-
RGB is a unit RGB tuple, return a gtk.gdk.Color
82+
Take a gtk.gdk.Color and return an RGB (a unit RGB tuple)
8483
"""
85-
8684
return [val/65535 for val in (color.red, color.green, color.blue)]
8785

8886
colorManager = ColorManagerGTK()
8987

90-
class RendererGTK(RendererBase):
9188

89+
class RendererGTK(RendererBase):
9290
fontweights = {
9391
100 : pango.WEIGHT_ULTRALIGHT,
9492
200 : pango.WEIGHT_LIGHT,

0 commit comments

Comments
 (0)