/[escript]/trunk/pyvisi/py_src/colormap.py
ViewVC logotype

Contents of /trunk/pyvisi/py_src/colormap.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 837 - (show annotations)
Tue Sep 5 07:23:50 2006 UTC (13 years, 11 months ago) by jongui
File MIME type: text/x-python
File size: 1950 byte(s)
added more epydocs and improved the way colors are specified in the driver.


1 """
2 Class that defines the mapping of colors.
3 """
4
5 class ColorMap:
6 """
7 @author: John Ngui
8 @author: Lutz Gross
9 """
10
11 def __init__(self, color_name):
12 """
13 @type color_name: String
14 @param color_name: Name of the color
15 """
16
17 self.color_name = color_name
18 self.colorMap = {}
19 self.buildColorMap()
20
21 def buildColorMap(self):
22 """
23 Build a hash that defines mapping of colors.
24 """
25
26 self.colorMap["Red"] = [255, 0, 0]
27 self.colorMap["Green"]= [0, 255, 0]
28 self.colorMap["Blue"] = [0, 0, 255]
29 self.colorMap["Black"] = [0, 0, 0]
30 self.colorMap["White"] = [255, 255, 255]
31 self.colorMap["Yelow"] = [255, 255, 0]
32 self.colorMap["Pink"] = [255, 20, 147]
33 self.colorMap["Orange"] = [255, 69, 0]
34 self.colorMap["Purple"] = [138, 43, 226]
35 self.colorMap["Grey"] = [169, 169, 169]
36 self.colorMap["Brown"] = [139, 69, 19]
37
38 def getR(self):
39 """
40 Return the red(R) value from the RGB.
41
42 @rtype: Number
43 @return: Red(R) value from the RGB
44 """
45
46 return self.colorMap[self.color_name][0]
47
48 def getG(self):
49 """
50 Return the green(G) value from the RGB.
51
52 @rtype: Number
53 @return: Green(R) value from the RGB
54 """
55
56 return self.colorMap[self.color_name][1]
57
58 def getB(self):
59 """
60 Return the blue(B) value from the RGB.
61
62 @rtype: Number
63 @return Blue(B) value from the RGB
64 """
65
66 return self.colorMap[self.color_name][2]
67
68 def getColor(self):
69 """
70 Return the name of the color.
71
72 @rtype: String
73 @return: Name of the color
74 """
75
76 return self.color_name
77
78 # Constants
79 RED = ColorMap("Red")
80 GREEN = ColorMap("Green")
81 BLUE = ColorMap("Blue")
82 BLACK = ColorMap("Black")
83 WHITE = ColorMap("White")
84 YELLOW = ColorMap("Yellow")
85 PINK = ColorMap("Pink")
86 ORANGE = ColorMap("Orange")
87 PURPLE = ColorMap("Purple")
88 GREY = ColorMap("Grey")
89 BROWN = ColorMap("Brown")
90
91
92 class BlueRed:
93 """
94 color map with spectrum from blue to red
95 """
96 pass
97
98 class RedBlue:
99 """
100 color map with spectrum from red to blue
101 """
102 pass

  ViewVC Help
Powered by ViewVC 1.1.26