Package mmLib :: Module Colors
[hide private]
[frames] | no frames]

Source Code for Module mmLib.Colors

 1  ## Copyright 2002-2010 by PyMMLib Development Group (see AUTHORS file) 
 2  ## This code is part of the PyMMLib distribution and governed by 
 3  ## its license.  Please see the LICENSE file that should have been 
 4  ## included as part of this package. 
 5  """Library of colors matching PyMol color names. 
 6  """ 
 7   
8 -def rgbf2rgbi(rgbf):
9 """Converts a RGB/float color into a RGB/integer. 10 """ 11 return (int(rgbf[0]*255.0), int(rgbf[1]*255.0), int(rgbf[2]*255.0))
12 13
14 -def rgbi2rgbf(rgbf):
15 """Converts a RGB/integer color into a RGB/float. 16 """ 17 return (int(rgbf[0]*255.0), int(rgbf[1]*255.0), int(rgbf[2]*255.0))
18 19 COLORS = [ 20 ('white', (1.0, 1.0, 1.0)), 21 ('black', (0.0, 0.0, 0.0)), 22 ('blue', (0.0, 0.0, 1.0)), 23 ('green', (0.0, 1.0, 0.0)), 24 ('magenta', (1.0, 0.0, 1.0)), 25 ('red', (1.0, 0.0, 0.0)), 26 ('cyan', (0.0, 1.0, 1.0)), 27 ('yellow', (1.0, 1.0, 0.0)), 28 ('violet', (1.0, 0.5, 1.0)), 29 ('purpleblue', (0.5, 0.0, 1.0)), 30 ('salmon', (1.0, 0.6, 0.5)), 31 ('lime', (0.5, 1.0, 0.5)), 32 ('slate', (0.5, 0.5, 1.0)), 33 ('bluegreen', (0.0, 1.0, 0.5)), 34 ('hotpink', (1.0, 0.0, 0.5)), 35 ('orange', (1.0, 0.5, 0.0)), 36 ('yellowgreen', (0.5, 1.0, 0.0)), 37 ('blueviolet', (0.5, 0.0, 1.0)), 38 ('marine', (0.0, 0.5, 1.0)), 39 ('olive', (0.75, 0.75, 0.0)), 40 ('purple', (0.75, 0.0, 0.75)), 41 ('teal', (0.0, 0.75, 0.75)), 42 ('ruby', (0.5, 0.1, 0.1)), 43 ('forest', (0.1, 0.5, 0.1)), 44 ('deep', (0.1, 0.1, 0.5)), 45 ('gray', (0.5, 0.5, 0.5)), 46 ('carbon', (0.2, 1.0, 0.2)), 47 ('nitrogen', (0.2, 0.2, 1.0)), 48 ('oxygen', (1.0, 0.3, 0.3)), 49 ('hydrogen', (0.9, 0.9, 0.9)), 50 ('brightorange', (1.0, 0.7, 0.2)), 51 ('sulfur', (1.0, 0.5, 0.0)), 52 ('tv_red', (1.0, 0.2, 0.2)), 53 ('tv_green', (0.2, 1.0, 0.2)), 54 ('tv_blue', (0.3, 0.3, 1.0)), 55 ('tv_yellow', (1.0, 1.0, 0.2)), 56 ('tv_orange', (1.0, 0.55, 0.15)), 57 ('br0', (0.1, 0.1, 1.0)), 58 ('br1', (0.2, 0.1, 0.9)), 59 ('br2', (0.3, 0.1, 0.8)), 60 ('br3', (0.4, 0.1, 0.7)), 61 ('br4', (0.5, 0.1, 0.6)), 62 ('br5', (0.6, 0.1, 0.5)), 63 ('br6', (0.7, 0.1, 0.4)), 64 ('br7', (0.8, 0.1, 0.3)), 65 ('br8', (0.9, 0.1, 0.2)), 66 ('br9', (1.0, 0.1, 0.1)), 67 ('pink', (1.0, 0.65, 0.85)), 68 ('firebrick', (0.697, 0.13, 0.13)), 69 ('chocolate', (0.555, 0.222, 0.111)), 70 ('brown', (0.555, 0.274, 0.15)), 71 ('wheat', (0.99, 0.82, 0.65)) 72 ] 73 74 COLOR_NAMES = [] 75 COLOR_NAMES_CAPITALIZED = [] 76 COLOR_RGBF = {} 77 COLOR_RGBI = {} 78 79 for name, rgb in COLORS: 80 COLOR_NAMES.append(name) 81 COLOR_NAMES_CAPITALIZED.append(name.capitalize()) 82 COLOR_RGBF[name] = rgb 83 COLOR_RGBI[name] = rgbf2rgbi(rgb) 84