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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 833 by jongui, Fri Sep 1 07:48:20 2006 UTC revision 837 by jongui, Tue Sep 5 07:23:50 2006 UTC
# Line 1  Line 1 
1  """  """
2  classes dealing with color maps  Class that defines the mapping of colors.
   
 @var __author__: name of author  
 @var __license__: licence agreement  
 @var __copyright__: copyrights  
 @var __url__: url entry point on documentation  
 @var __version__: version  
 @var __date__: date of the version  
3  """  """
4    
 __copyright__="""  Copyright (c) 2006 by ACcESS MNRF  
                     http://www.access.edu.au  
                 Primary Business: Queensland, Australia"""  
 __license__="""Licensed under the Open Software License version 3.0  
              http://www.opensource.org/licenses/osl-3.0.php"""  
 __author__="Paul Cochrane"  
 __url__="http://www.iservo.edu.au/esys"  
 __version__="$Revision$"  
 __date__="$Date$"  
   
5  class ColorMap:  class ColorMap:
6     """      """
7     defines a color map      @author: John Ngui
8     """      @author: Lutz Gross
9     pass      """
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:  class BlueRed:
93     """     """

Legend:
Removed from v.833  
changed lines
  Added in v.837

  ViewVC Help
Powered by ViewVC 1.1.26