packmol-memgen-minimal 1.1.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- packmol_memgen/__init__.py +2 -0
- packmol_memgen/__version__.py +34 -0
- packmol_memgen/data/LICENSE.Apache-2.0 +201 -0
- packmol_memgen/data/extra_solvents.lib +789 -0
- packmol_memgen/data/frcmod.lipid_ext +97 -0
- packmol_memgen/data/frcmod.solvents +129 -0
- packmol_memgen/data/insane_lipids.txt +138 -0
- packmol_memgen/data/insane_solvents.txt +45 -0
- packmol_memgen/data/leaprc.extra_solvents +42 -0
- packmol_memgen/data/leaprc.lipid_ext +48 -0
- packmol_memgen/data/lipid_ext.lib +12312 -0
- packmol_memgen/data/martini_v3.0.0.itp +356605 -0
- packmol_memgen/data/memgen.parm +4082 -0
- packmol_memgen/data/pdbs.tar.gz +0 -0
- packmol_memgen/data/solvent.parm +14 -0
- packmol_memgen/example/example.sh +31 -0
- packmol_memgen/lib/__init__.py +0 -0
- packmol_memgen/lib/amber.py +77 -0
- packmol_memgen/lib/charmmlipid2amber/__init__.py +0 -0
- packmol_memgen/lib/charmmlipid2amber/charmmlipid2amber.csv +7164 -0
- packmol_memgen/lib/charmmlipid2amber/charmmlipid2amber.py +225 -0
- packmol_memgen/lib/pdbremix/LICENSE +21 -0
- packmol_memgen/lib/pdbremix/__init__.py +0 -0
- packmol_memgen/lib/pdbremix/_version.py +1 -0
- packmol_memgen/lib/pdbremix/amber.py +1103 -0
- packmol_memgen/lib/pdbremix/asa.py +227 -0
- packmol_memgen/lib/pdbremix/data/aminoacid.pdb +334 -0
- packmol_memgen/lib/pdbremix/data/binaries.json +26 -0
- packmol_memgen/lib/pdbremix/data/charmm22.parameter +2250 -0
- packmol_memgen/lib/pdbremix/data/charmm22.topology +1635 -0
- packmol_memgen/lib/pdbremix/data/color_b.py +682 -0
- packmol_memgen/lib/pdbremix/data/hin.lib +130 -0
- packmol_memgen/lib/pdbremix/data/hydroxide.lib +88 -0
- packmol_memgen/lib/pdbremix/data/make_chi.py +92 -0
- packmol_memgen/lib/pdbremix/data/opls.parameter +1108 -0
- packmol_memgen/lib/pdbremix/data/opls.topology +1869 -0
- packmol_memgen/lib/pdbremix/data/phd.frcmod +82 -0
- packmol_memgen/lib/pdbremix/data/phd.leaprc +4 -0
- packmol_memgen/lib/pdbremix/data/phd.prepin +35 -0
- packmol_memgen/lib/pdbremix/data/template.pdb +334 -0
- packmol_memgen/lib/pdbremix/data/znb.frcmod +24 -0
- packmol_memgen/lib/pdbremix/data/znb.leaprc +7 -0
- packmol_memgen/lib/pdbremix/data/znb.lib +69 -0
- packmol_memgen/lib/pdbremix/data.py +264 -0
- packmol_memgen/lib/pdbremix/fetch.py +102 -0
- packmol_memgen/lib/pdbremix/force.py +627 -0
- packmol_memgen/lib/pdbremix/gromacs.py +978 -0
- packmol_memgen/lib/pdbremix/lib/__init__.py +0 -0
- packmol_memgen/lib/pdbremix/lib/docopt.py +579 -0
- packmol_memgen/lib/pdbremix/lib/pyqcprot.py +305 -0
- packmol_memgen/lib/pdbremix/namd.py +1078 -0
- packmol_memgen/lib/pdbremix/pdbatoms.py +543 -0
- packmol_memgen/lib/pdbremix/pdbtext.py +120 -0
- packmol_memgen/lib/pdbremix/protein.py +311 -0
- packmol_memgen/lib/pdbremix/pymol.py +480 -0
- packmol_memgen/lib/pdbremix/rmsd.py +203 -0
- packmol_memgen/lib/pdbremix/simulate.py +420 -0
- packmol_memgen/lib/pdbremix/spacehash.py +73 -0
- packmol_memgen/lib/pdbremix/trajectory.py +286 -0
- packmol_memgen/lib/pdbremix/util.py +273 -0
- packmol_memgen/lib/pdbremix/v3.py +16 -0
- packmol_memgen/lib/pdbremix/v3array.py +482 -0
- packmol_memgen/lib/pdbremix/v3numpy.py +350 -0
- packmol_memgen/lib/pdbremix/volume.py +155 -0
- packmol_memgen/lib/utils.py +1017 -0
- packmol_memgen/main.py +2827 -0
- packmol_memgen_minimal-1.1.16.dist-info/METADATA +664 -0
- packmol_memgen_minimal-1.1.16.dist-info/RECORD +71 -0
- packmol_memgen_minimal-1.1.16.dist-info/WHEEL +4 -0
- packmol_memgen_minimal-1.1.16.dist-info/entry_points.txt +2 -0
- packmol_memgen_minimal-1.1.16.dist-info/licenses/LICENSE +338 -0
|
@@ -0,0 +1,682 @@
|
|
|
1
|
+
# rlc color_b.py version 8.0
|
|
2
|
+
# Copyright (c) 2004 Robert L. Campbell
|
|
3
|
+
# added user defined colors for 3 color ramp- Mark A. Wall
|
|
4
|
+
|
|
5
|
+
import colorsys,sys,re
|
|
6
|
+
from pymol import cmd
|
|
7
|
+
|
|
8
|
+
# main function called from within PyMOL
|
|
9
|
+
def color_b(selection='all',item='b',mode='hist',gradient='bgr',nbins=11,sat=1.,value=1.,minimum='',maximum='',user_rgb=''):
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
AUTHOR
|
|
13
|
+
|
|
14
|
+
Robert L. Campbell with enhancements from James Stroud
|
|
15
|
+
|
|
16
|
+
USAGE
|
|
17
|
+
|
|
18
|
+
color_b selection='sel',item='b', 'q', 'partial_charge' or 'formal_charge'
|
|
19
|
+
gradient='bgr' or 'rgb' or 'bwr' or 'rwb' or 'bmr' or 'rmb' or
|
|
20
|
+
'rw' or 'wr' or 'gw' or 'wg' or 'bw' or wb' or 'gy' or 'yg' or
|
|
21
|
+
'gray' or 'reversegray' or 'user'
|
|
22
|
+
|
|
23
|
+
mode='hist' or 'ramp' (default is 'hist')
|
|
24
|
+
|
|
25
|
+
[minimum=''],[maximum=20.],
|
|
26
|
+
|
|
27
|
+
nbins=11, sat=1.0, value=1.0,
|
|
28
|
+
|
|
29
|
+
user_rgb = '(r1,g1,b1,r2,g2,b2,r3,g3,b3') [for use with gradient=user]
|
|
30
|
+
|
|
31
|
+
The "item" argument allows specifying 'b', 'q', 'partial_charge'
|
|
32
|
+
or 'formal_charge'as the item to color on. The "color_q" function
|
|
33
|
+
is really just the same as "color_b item=q".
|
|
34
|
+
|
|
35
|
+
This function allows coloring of a selection as a function of
|
|
36
|
+
B-value or occupancy, following a gradient of colours. The
|
|
37
|
+
gradients can be:
|
|
38
|
+
|
|
39
|
+
'bgr': blue -> green -> red
|
|
40
|
+
'rgb': red -> green -> blue
|
|
41
|
+
'bwr': blue -> white -> red
|
|
42
|
+
'rwb': red -> white -> blue
|
|
43
|
+
'bmr': blue -> magenta -> red
|
|
44
|
+
'rmb': red -> magenta -> blue
|
|
45
|
+
'rw' : red -> white
|
|
46
|
+
'wr' : white -> red
|
|
47
|
+
'gw' : green -> white
|
|
48
|
+
'wg' : white -> green
|
|
49
|
+
'bw' : blue -> white
|
|
50
|
+
'wb' : white -> blue
|
|
51
|
+
'gy' : green -> yellow
|
|
52
|
+
'yg' : yellow -> green
|
|
53
|
+
'gray' : black -> white
|
|
54
|
+
'reversegray' : white -> black
|
|
55
|
+
'user' : user defined in this script
|
|
56
|
+
|
|
57
|
+
('rainbow' and 'reverserainbow' can be used as synonyms for
|
|
58
|
+
'bgr' and 'rgb' respectively and 'grey' can be used as a synonym for 'gray').
|
|
59
|
+
|
|
60
|
+
User-defined gradients are entered on the command line in
|
|
61
|
+
parentheses as either integers between 0 and 255 or floats between
|
|
62
|
+
0 and 1. If any one value is larger than 1, then it is assumed
|
|
63
|
+
that all are being entered as integers between 0 and 255. Hence one can type:
|
|
64
|
+
|
|
65
|
+
color_b selection, gradient=user, user_rgb=(0,0,1, 0,.5,1., 1.,.5,0.)
|
|
66
|
+
|
|
67
|
+
or
|
|
68
|
+
|
|
69
|
+
color_b selection, gradient=user, user_rgb=(0,0,255, 0,128,255, 255,128,0.)
|
|
70
|
+
|
|
71
|
+
The division of B-value ranges can in either of two modes: 'hist' or
|
|
72
|
+
'ramp'. 'hist' is like a histogram (equal-sized B-value increments
|
|
73
|
+
leading to unequal numbers of atoms in each bin). 'ramp' as a ramp
|
|
74
|
+
of B-value ranges with the ranges chosen to provide an equal number
|
|
75
|
+
of atoms in each group.
|
|
76
|
+
|
|
77
|
+
You can also specify the lower or upper limits of the data used to determine
|
|
78
|
+
the color bins (minimum,maximum). e.g. color_b my_molecule, minimum=15., maximum=25.
|
|
79
|
+
|
|
80
|
+
You can also specify the saturation and value (i.e. the "s" and "v"
|
|
81
|
+
in the "HSV" color scheme) to be used for the gradient. The defaults
|
|
82
|
+
are 1.0 for both "sat" and "value".
|
|
83
|
+
|
|
84
|
+
In the case of the gray scale gradients, "sat" sets the minimum intensity
|
|
85
|
+
(normally black) and "value" sets the maximum (normally white)
|
|
86
|
+
|
|
87
|
+
usage:
|
|
88
|
+
from within PyMOL do "run color_b.py" to load the function definition.
|
|
89
|
+
Then you can use for example:
|
|
90
|
+
|
|
91
|
+
color_b (c. a | c. b),mode=ramp,gradient=bwr,nbins=30,sat=.5, value=1.
|
|
92
|
+
|
|
93
|
+
to color chains A and B with the Blue-White-Red gradient in 30 colors of equal
|
|
94
|
+
numbers of atoms in each color.
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
nbins=int(nbins)
|
|
98
|
+
sat=float(sat)
|
|
99
|
+
value=float(value)
|
|
100
|
+
# make sure sat and value are in the range 0-1.0
|
|
101
|
+
sat = min(sat, 1.0)
|
|
102
|
+
sat = max(sat, 0.0)
|
|
103
|
+
value = min(value, 1.0)
|
|
104
|
+
value = max(value, 0.0)
|
|
105
|
+
if gradient == 'user' and user_rgb == '':
|
|
106
|
+
user_rgb = '50,50,195, 245,245,20, 255,20,20'
|
|
107
|
+
|
|
108
|
+
# make sure lowercase
|
|
109
|
+
gradient.lower()
|
|
110
|
+
mode.lower()
|
|
111
|
+
|
|
112
|
+
# Sanity checking
|
|
113
|
+
if nbins == 1:
|
|
114
|
+
print("\n WARNING: You specified nbins=1, which doesn't make sense...resetting nbins=11\n")
|
|
115
|
+
nbins=11
|
|
116
|
+
|
|
117
|
+
if mode not in ('hist','ramp'):
|
|
118
|
+
print("\n WARNING: Unknown mode ",mode, " -----> Nothing done.\n")
|
|
119
|
+
return
|
|
120
|
+
elif gradient not in ('bgr','rgb','rainbow','reverserainbow','bwr','rwb','user',
|
|
121
|
+
'bmr','rmb','rw','wr','gw','wg','bw','wb','gy','yg','gray','grey','reversegray','reversegrey','user'):
|
|
122
|
+
print("\n WARNING: Unknown gradient: ",gradient, " -----> Nothing done.\n")
|
|
123
|
+
return
|
|
124
|
+
|
|
125
|
+
print("MODE, GRADIENT, NBINS:", mode,gradient, nbins)
|
|
126
|
+
|
|
127
|
+
# get list of B-factors from selection
|
|
128
|
+
m = cmd.get_model(selection)
|
|
129
|
+
sel = []
|
|
130
|
+
b_list = []
|
|
131
|
+
|
|
132
|
+
if len(m.atom) == 0:
|
|
133
|
+
print("Sorry, no atoms selected")
|
|
134
|
+
|
|
135
|
+
else:
|
|
136
|
+
if item == 'b':
|
|
137
|
+
for i in range(len(m.atom)):
|
|
138
|
+
b_list.append(m.atom[i].b)
|
|
139
|
+
elif item == 'q':
|
|
140
|
+
for i in range(len(m.atom)):
|
|
141
|
+
b_list.append(m.atom[i].q)
|
|
142
|
+
|
|
143
|
+
elif item == 'partial_charge':
|
|
144
|
+
for i in range(len(m.atom)):
|
|
145
|
+
b_list.append(m.atom[i].partial_charge)
|
|
146
|
+
|
|
147
|
+
elif item == 'formal_charge':
|
|
148
|
+
for i in range(len(m.atom)):
|
|
149
|
+
b_list.append(m.atom[i].formal_charge)
|
|
150
|
+
|
|
151
|
+
else:
|
|
152
|
+
print("Not configured to work on item %s" % item)
|
|
153
|
+
return
|
|
154
|
+
|
|
155
|
+
max_b = max(b_list)
|
|
156
|
+
min_b = min(b_list)
|
|
157
|
+
print("Minimum and Maximum B-values: ", min_b, max_b)
|
|
158
|
+
|
|
159
|
+
if mode == 'ramp':
|
|
160
|
+
# color in bins of equal numbers of atoms
|
|
161
|
+
b_list.sort()
|
|
162
|
+
|
|
163
|
+
# subtract 0.1 from the lowest B in order to ensure that the single
|
|
164
|
+
# atom with the lowest B value doesn't get omitted
|
|
165
|
+
# b_list[0] = b_list[0] - 0.1
|
|
166
|
+
|
|
167
|
+
bin_num = int(len(b_list)/nbins)
|
|
168
|
+
# sel.append(selection + " and (b < " + str(b_list[bin_num]) + " or b = " + str(b_list[bin_num]) + ")")
|
|
169
|
+
sel.append(selection + " and (%s < %4.4g" % (item,b_list[bin_num]) + " or %s = %4.4g" % (item,b_list[bin_num]) + ")")
|
|
170
|
+
for j in range(1,nbins):
|
|
171
|
+
# sel.append(selection + " and b > " + str(b_list[j*bin_num]))
|
|
172
|
+
sel.append(selection + " and %s > %4.4g" % (item,b_list[j*bin_num]))
|
|
173
|
+
#print "Color select: ",sel[j]
|
|
174
|
+
|
|
175
|
+
elif mode == 'hist':
|
|
176
|
+
|
|
177
|
+
# check if minimum or maximum was specified and use the entered values
|
|
178
|
+
if minimum != '':
|
|
179
|
+
min_b = float(minimum)
|
|
180
|
+
if maximum != '':
|
|
181
|
+
max_b = float(maximum)
|
|
182
|
+
# histogram:
|
|
183
|
+
# color in bins of equal B-value ranges
|
|
184
|
+
# subtract 0.1 from the lowest B in order to ensure that the single
|
|
185
|
+
# atom with the lowest B value doesn't get omitted
|
|
186
|
+
bin_width = (max_b - min_b)/nbins
|
|
187
|
+
sel.append(selection + " and (%s < %4.4g" % (item,min_b + bin_width) + " or %s = %4.4g" % (item,min_b + bin_width) + ")")
|
|
188
|
+
for j in range(1,nbins):
|
|
189
|
+
sel.append(selection + " and %s > %4.4g" % (item,min_b + j*bin_width))
|
|
190
|
+
#print "Color select: ",sel[j]
|
|
191
|
+
|
|
192
|
+
# call the function to create the gradient which returns a list of colours
|
|
193
|
+
colours = make_gradient(sel,gradient,nbins,sat,value, user_rgb)
|
|
194
|
+
|
|
195
|
+
# do the colouring now
|
|
196
|
+
for j in range(nbins):
|
|
197
|
+
print("Color select: ",sel[j])
|
|
198
|
+
cmd.color(colours[j],sel[j])
|
|
199
|
+
|
|
200
|
+
def color_q(selection="all",mode="hist",gradient="bgr",nbins=11,sat=1.,value=1.,minimum='',maximum=''):
|
|
201
|
+
"""
|
|
202
|
+
|
|
203
|
+
USAGE
|
|
204
|
+
|
|
205
|
+
color_q(selection,gradient,mode,nbins,sat,value) ='sel',
|
|
206
|
+
gradient='bgr' or 'rgb' or 'bwr' or 'rwb' or 'bmr' or 'rmb'
|
|
207
|
+
'rw' or 'wr','gw' or 'wg' or 'bw' or 'wb' or 'gy' or 'yg' or 'gray' or 'reversegray' or 'user'
|
|
208
|
+
mode='hist' or 'ramp', q0=0.,q1=1.0,
|
|
209
|
+
nbins=11, sat=1.0, value=1.0)
|
|
210
|
+
|
|
211
|
+
This function allows coloring of a selection as a function of
|
|
212
|
+
occupancy. See color_b for details.
|
|
213
|
+
"""
|
|
214
|
+
item='q'
|
|
215
|
+
color_b(selection,item,mode,gradient,nbins,sat,value,minimum,maximum)
|
|
216
|
+
|
|
217
|
+
# function for creating the gradient
|
|
218
|
+
def make_gradient(sel,gradient,nbins,sat,value,user_rgb):
|
|
219
|
+
if gradient == 'bgr' or gradient == 'rainbow':
|
|
220
|
+
col=[]
|
|
221
|
+
coldesc=[]
|
|
222
|
+
for j in range(nbins):
|
|
223
|
+
# must append the str(sel[j]) to the color name so that it is unique
|
|
224
|
+
# for the selection
|
|
225
|
+
coldesc.append('col' + str(j))
|
|
226
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
227
|
+
|
|
228
|
+
# create colors using hsv scale (fractional) starting at blue(.6666667)
|
|
229
|
+
# through red(0.00000) in intervals of .6666667/(nbins -1) (the "nbins-1"
|
|
230
|
+
# ensures that the last color is, in fact, red (0)
|
|
231
|
+
# rewrote this to use the colorsys module to convert hsv to rgb
|
|
232
|
+
hsv = (colorsys.TWO_THIRD - colorsys.TWO_THIRD * float(j) / (nbins-1), sat, value)
|
|
233
|
+
#convert to rgb and append to color list
|
|
234
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
235
|
+
|
|
236
|
+
col.append(rgb)
|
|
237
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
238
|
+
cmd.set_color("col" + str(j),col[j])
|
|
239
|
+
# print "defined as ", str(sel[j])
|
|
240
|
+
|
|
241
|
+
elif gradient == 'user':
|
|
242
|
+
# --------------------------------------------
|
|
243
|
+
# Modified color ramp by Mark Wall 2007.07.20
|
|
244
|
+
# --------------------------------------------
|
|
245
|
+
# assign 3-color ramp values (rgb 0-255)
|
|
246
|
+
# could easily assign RGB color values between 0.0 and 1.0 below
|
|
247
|
+
# !!! Black must be at least 1,0,0 or div by zero error !!!
|
|
248
|
+
#
|
|
249
|
+
#r1, g1, b1 = 255, 255, 225 # low white
|
|
250
|
+
#r1, g1, b1 = 170, 170, 170 # low gray
|
|
251
|
+
user_rgb = re.compile('[\[\](){}]').sub('',user_rgb)
|
|
252
|
+
user_rgb_fract = 0
|
|
253
|
+
try:
|
|
254
|
+
r1,g1,b1, r2,g2,b2, r3,g3,b3 = list(map(int,user_rgb.split(',')))
|
|
255
|
+
except ValueError:
|
|
256
|
+
r1,g1,b1, r2,g2,b2, r3,g3,b3 = list(map(float,user_rgb.split(',')))
|
|
257
|
+
user_rgb_fract = 1
|
|
258
|
+
|
|
259
|
+
print('user_rgb', r1,g1,b1, r2,g2,b2, r3,g3,b3)
|
|
260
|
+
|
|
261
|
+
# r1, g1, b1 = 50, 50, 195 # low med blue
|
|
262
|
+
# r2, g2, b2 = 245, 245, 20 # mid yellow
|
|
263
|
+
# r3, g3, b3 = 255, 20, 20 # high red
|
|
264
|
+
#
|
|
265
|
+
#r1, g1, b1 = 255, 20, 20 # low red
|
|
266
|
+
#r2, g2, b2 = 150, 150, 20 # mid yellow
|
|
267
|
+
#r3, g3, b3 = 20, 20, 195 # high med blue
|
|
268
|
+
#
|
|
269
|
+
#r1, g1, b1 = 1, 0, 0 # low black
|
|
270
|
+
#r2, g2, b2 = 155, 155, 155 # mid gray
|
|
271
|
+
#r3, g3, b3 = 255, 255, 255 # high white
|
|
272
|
+
#
|
|
273
|
+
#r1, g1, b1 = 0, 50, 200 # low blue
|
|
274
|
+
#r2, g2, b2 = 1, 0, 0 # mid black
|
|
275
|
+
#r3, g3, b3 = 255, 255, 20 # high yellow
|
|
276
|
+
#
|
|
277
|
+
#r1, g1, b1 = 0, 0, 1 # low black
|
|
278
|
+
#r2, g2, b2 = 200, 0, 0 # mid red
|
|
279
|
+
#r3, g3, b3 = 255, 255, 0 # high yellow
|
|
280
|
+
#
|
|
281
|
+
#r1, g1, b1 = 180, 170, 170 # low gray
|
|
282
|
+
#r2, g2, b2 = 250, 90, 40 # mid orange
|
|
283
|
+
#r3, g3, b3 = 255, 255, 0 # high yellow
|
|
284
|
+
#
|
|
285
|
+
#r1, g1, b1 = 235, 255, 255 # low white
|
|
286
|
+
#r2, g2, b2 = 55, 255, 255 # mid cyan
|
|
287
|
+
#r3, g3, b3 = 0, 0, 180 # high blue
|
|
288
|
+
#
|
|
289
|
+
# change color values to fractions
|
|
290
|
+
#
|
|
291
|
+
if max(r1,g1,b1,r2,g2,b2,r3,g3,b3) > 1:
|
|
292
|
+
r1, g1, b1 = float(r1)/255.0, float(g1)/255.0, float(b1)/255.0
|
|
293
|
+
r2, g2, b2 = float(r2)/255.0, float(g2)/255.0, float(b2)/255.0
|
|
294
|
+
r3, g3, b3 = float(r3)/255.0, float(g3)/255.0, float(b3)/255.0
|
|
295
|
+
|
|
296
|
+
col=[]
|
|
297
|
+
coldesc=[]
|
|
298
|
+
# print "r1,g1,b1, r2,g2,b2, r3,g3,b3", r1,g1,b1, r2,g2,b2, r3,g3,b3
|
|
299
|
+
for j in range(nbins/2):
|
|
300
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
301
|
+
coldesc.append('col' + str(j))
|
|
302
|
+
# create colors in a gradient from low to mid
|
|
303
|
+
rgb = [r1*((float(nbins)-float(j)*2.0)/float(nbins))+r2*(float(j)*2.0/float(nbins)), \
|
|
304
|
+
g1*((float(nbins)-float(j)*2.0)/float(nbins))+g2*(float(j)*2.0/float(nbins)), \
|
|
305
|
+
b1*((float(nbins)-float(j)*2.0)/float(nbins))+b2*(float(j)*2.0/float(nbins))]
|
|
306
|
+
|
|
307
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
308
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
309
|
+
hsv[1] = hsv[1]*sat
|
|
310
|
+
hsv[2] = hsv[2]*value
|
|
311
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
312
|
+
print(j,"rgb: %4.3f %4.3f %4.3f"% rgb)
|
|
313
|
+
|
|
314
|
+
col.append(rgb)
|
|
315
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
316
|
+
cmd.set_color("col" + str(j),col[j])
|
|
317
|
+
|
|
318
|
+
for j in range(nbins/2,nbins):
|
|
319
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
320
|
+
coldesc.append('col' + str(j))
|
|
321
|
+
# create colors in a gradient from mid to high
|
|
322
|
+
rgb = [r2*((float(nbins)-((float(j+1)-float(nbins)/2.0)*2.0))/float(nbins))+r3*(((float(j+1)-float(nbins)/2.0)*2.0)/float(nbins)), \
|
|
323
|
+
g2*((float(nbins)-((float(j+1)-float(nbins)/2.0)*2.0))/float(nbins))+g3*(((float(j+1)-float(nbins)/2.0)*2.0)/float(nbins)), \
|
|
324
|
+
b2*((float(nbins)-((float(j+1)-float(nbins)/2.0)*2.0))/float(nbins))+b3*(((float(j+1)-float(nbins)/2.0)*2.0)/float(nbins))]
|
|
325
|
+
|
|
326
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
327
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
328
|
+
hsv[1] = hsv[1]*sat
|
|
329
|
+
hsv[2] = hsv[2]*value
|
|
330
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
331
|
+
print(j,"rgb: %4.3f %4.3f %4.3f"% rgb)
|
|
332
|
+
|
|
333
|
+
col.append(rgb)
|
|
334
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
335
|
+
cmd.set_color("col" + str(j),col[j])
|
|
336
|
+
|
|
337
|
+
elif gradient == 'rgb' or gradient == 'reverserainbow':
|
|
338
|
+
col=[]
|
|
339
|
+
coldesc=[]
|
|
340
|
+
for j in range(nbins):
|
|
341
|
+
# must append the str(sel[j]) to the color name so that it is unique
|
|
342
|
+
# for the selection
|
|
343
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
344
|
+
coldesc.append('col' + str(j))
|
|
345
|
+
|
|
346
|
+
# create colors using hsv scale (fractional) starting at red(.00000)
|
|
347
|
+
# through blue(0.66667) in intervals of .6666667/(nbins -1) (the "nbins-1"
|
|
348
|
+
# ensures that the last color is, in fact, red (0)
|
|
349
|
+
# rewrote this to use the colorsys module to convert hsv to rgb
|
|
350
|
+
hsv = (colorsys.TWO_THIRD * float(j) / (nbins-1), sat, value)
|
|
351
|
+
#convert to rgb and append to color list
|
|
352
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
353
|
+
|
|
354
|
+
col.append(rgb)
|
|
355
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
356
|
+
cmd.set_color("col" + str(j),col[j])
|
|
357
|
+
|
|
358
|
+
elif gradient == 'bmr':
|
|
359
|
+
col=[]
|
|
360
|
+
coldesc=[]
|
|
361
|
+
for j in range(nbins):
|
|
362
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
363
|
+
coldesc.append('col' + str(j))
|
|
364
|
+
# create colors in a gradient from blue through magenta to red
|
|
365
|
+
rgb = [min(1.0, float(j)*2/(nbins-1)), 0.0, min(1.0, float(nbins-j-1)*2/(nbins-1))]
|
|
366
|
+
|
|
367
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
368
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
369
|
+
hsv[1] = hsv[1]*sat
|
|
370
|
+
hsv[2] = hsv[2]*value
|
|
371
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
372
|
+
|
|
373
|
+
col.append(rgb)
|
|
374
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
375
|
+
cmd.set_color("col" + str(j),col[j])
|
|
376
|
+
|
|
377
|
+
elif gradient == 'rmb':
|
|
378
|
+
col=[]
|
|
379
|
+
coldesc=[]
|
|
380
|
+
for j in range(nbins):
|
|
381
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
382
|
+
coldesc.append('col' + str(j))
|
|
383
|
+
# create colors in a gradient from red through magenta to blue
|
|
384
|
+
rgb = [min(1.0, float(nbins-j-1)*2/(nbins-1)), 0.0, min(1.0, float(j)*2/(nbins-1))]
|
|
385
|
+
|
|
386
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
387
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
388
|
+
hsv[1] = hsv[1]*sat
|
|
389
|
+
hsv[2] = hsv[2]*value
|
|
390
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
391
|
+
|
|
392
|
+
col.append(rgb)
|
|
393
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
394
|
+
cmd.set_color("col" + str(j),col[j])
|
|
395
|
+
|
|
396
|
+
elif gradient == 'rw':
|
|
397
|
+
col=[]
|
|
398
|
+
coldesc=[]
|
|
399
|
+
for j in range(nbins):
|
|
400
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
401
|
+
coldesc.append('col' + str(j))
|
|
402
|
+
# create colors in a gradient from red through white
|
|
403
|
+
rgb = [1.0, float(j)/(nbins-1), float(j)/(nbins-1)]
|
|
404
|
+
|
|
405
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
406
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
407
|
+
hsv[1] = hsv[1]*sat
|
|
408
|
+
hsv[2] = hsv[2]*value
|
|
409
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
410
|
+
|
|
411
|
+
col.append(rgb)
|
|
412
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
413
|
+
cmd.set_color("col" + str(j),col[j])
|
|
414
|
+
|
|
415
|
+
elif gradient == 'wr':
|
|
416
|
+
col=[]
|
|
417
|
+
coldesc=[]
|
|
418
|
+
for j in range(nbins):
|
|
419
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
420
|
+
coldesc.append('col' + str(j))
|
|
421
|
+
# create colors in a gradient from white through red
|
|
422
|
+
rgb = [1.0, float(nbins-j-1)/(nbins-1), float(nbins-j-1)/(nbins-1)]
|
|
423
|
+
|
|
424
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
425
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
426
|
+
hsv[1] = hsv[1]*sat
|
|
427
|
+
hsv[2] = hsv[2]*value
|
|
428
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
429
|
+
|
|
430
|
+
col.append(rgb)
|
|
431
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
432
|
+
cmd.set_color("col" + str(j),col[j])
|
|
433
|
+
|
|
434
|
+
elif gradient == 'gw':
|
|
435
|
+
col=[]
|
|
436
|
+
coldesc=[]
|
|
437
|
+
for j in range(nbins):
|
|
438
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
439
|
+
coldesc.append('col' + str(j))
|
|
440
|
+
# create colors in a gradient from green through white
|
|
441
|
+
rgb = [float(j)/(nbins-1), 1.0, float(j)/(nbins-1)]
|
|
442
|
+
|
|
443
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
444
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
445
|
+
hsv[1] = hsv[1]*sat
|
|
446
|
+
hsv[2] = hsv[2]*value
|
|
447
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
448
|
+
|
|
449
|
+
col.append(rgb)
|
|
450
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
451
|
+
cmd.set_color("col" + str(j),col[j])
|
|
452
|
+
|
|
453
|
+
elif gradient == 'wg':
|
|
454
|
+
col=[]
|
|
455
|
+
coldesc=[]
|
|
456
|
+
for j in range(nbins):
|
|
457
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
458
|
+
coldesc.append('col' + str(j))
|
|
459
|
+
# create colors in a gradient from white through green
|
|
460
|
+
rgb = [float(nbins-j-1)/(nbins-1), 1.0, float(nbins-j-1)/(nbins-1)]
|
|
461
|
+
|
|
462
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
463
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
464
|
+
hsv[1] = hsv[1]*sat
|
|
465
|
+
hsv[2] = hsv[2]*value
|
|
466
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
467
|
+
|
|
468
|
+
col.append(rgb)
|
|
469
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
470
|
+
cmd.set_color("col" + str(j),col[j])
|
|
471
|
+
|
|
472
|
+
elif gradient == 'bw':
|
|
473
|
+
col=[]
|
|
474
|
+
coldesc=[]
|
|
475
|
+
for j in range(nbins):
|
|
476
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
477
|
+
coldesc.append('col' + str(j))
|
|
478
|
+
# create colors in a gradient from blue through white
|
|
479
|
+
rgb = [float(j)/(nbins-1), float(j)/(nbins-1), 1.0 ]
|
|
480
|
+
|
|
481
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
482
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
483
|
+
hsv[1] = hsv[1]*sat
|
|
484
|
+
hsv[2] = hsv[2]*value
|
|
485
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
486
|
+
|
|
487
|
+
col.append(rgb)
|
|
488
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
489
|
+
cmd.set_color("col" + str(j),col[j])
|
|
490
|
+
|
|
491
|
+
elif gradient == 'wb':
|
|
492
|
+
col=[]
|
|
493
|
+
coldesc=[]
|
|
494
|
+
for j in range(nbins):
|
|
495
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
496
|
+
coldesc.append('col' + str(j))
|
|
497
|
+
# create colors in a gradient from blue through white
|
|
498
|
+
rgb = [float(nbins-j-1)/(nbins-1), float(nbins-j-1)/(nbins-1), 1.0 ]
|
|
499
|
+
|
|
500
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
501
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
502
|
+
hsv[1] = hsv[1]*sat
|
|
503
|
+
hsv[2] = hsv[2]*value
|
|
504
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
505
|
+
|
|
506
|
+
col.append(rgb)
|
|
507
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
508
|
+
cmd.set_color("col" + str(j),col[j])
|
|
509
|
+
|
|
510
|
+
elif gradient == 'wr':
|
|
511
|
+
col=[]
|
|
512
|
+
coldesc=[]
|
|
513
|
+
for j in range(nbins):
|
|
514
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
515
|
+
coldesc.append('col' + str(j))
|
|
516
|
+
# create colors in a gradient from white through blue
|
|
517
|
+
rgb = [float(nbins-j-1)/(nbins-1), float(nbins-j-1)/(nbins-1), 1.0]
|
|
518
|
+
|
|
519
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
520
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
521
|
+
hsv[1] = hsv[1]*sat
|
|
522
|
+
hsv[2] = hsv[2]*value
|
|
523
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
524
|
+
|
|
525
|
+
col.append(rgb)
|
|
526
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
527
|
+
cmd.set_color("col" + str(j),col[j])
|
|
528
|
+
|
|
529
|
+
elif gradient == 'gy':
|
|
530
|
+
col=[]
|
|
531
|
+
coldesc=[]
|
|
532
|
+
for j in range(nbins):
|
|
533
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
534
|
+
coldesc.append('col' + str(j))
|
|
535
|
+
# create colors in a gradient from green through yellow
|
|
536
|
+
rgb = [float(j)/(nbins-1), 1.0, 0.]
|
|
537
|
+
|
|
538
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
539
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
540
|
+
hsv[1] = hsv[1]*sat
|
|
541
|
+
hsv[2] = hsv[2]*value
|
|
542
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
543
|
+
|
|
544
|
+
col.append(rgb)
|
|
545
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
546
|
+
cmd.set_color("col" + str(j),col[j])
|
|
547
|
+
|
|
548
|
+
elif gradient == 'yg':
|
|
549
|
+
col=[]
|
|
550
|
+
coldesc=[]
|
|
551
|
+
for j in range(nbins):
|
|
552
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
553
|
+
coldesc.append('col' + str(j))
|
|
554
|
+
# create colors in a gradient from green through yellow
|
|
555
|
+
rgb = [float(nbins-j-1)/(nbins-1), 1.0, 0.]
|
|
556
|
+
|
|
557
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
558
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
559
|
+
hsv[1] = hsv[1]*sat
|
|
560
|
+
hsv[2] = hsv[2]*value
|
|
561
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
562
|
+
|
|
563
|
+
col.append(rgb)
|
|
564
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
565
|
+
cmd.set_color("col" + str(j),col[j])
|
|
566
|
+
|
|
567
|
+
elif gradient == 'bwr':
|
|
568
|
+
col=[]
|
|
569
|
+
coldesc=[]
|
|
570
|
+
for j in range(nbins/2):
|
|
571
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
572
|
+
coldesc.append('col' + str(j))
|
|
573
|
+
# create colors in a gradient from blue to white
|
|
574
|
+
rgb = [min(1.0, float(j)*2/(nbins-1)), min(1.0,float(j)*2/(nbins-1)), min(1.0, float(nbins-j-1)*2/(nbins-1))]
|
|
575
|
+
|
|
576
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
577
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
578
|
+
hsv[1] = hsv[1]*sat
|
|
579
|
+
hsv[2] = hsv[2]*value
|
|
580
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
581
|
+
|
|
582
|
+
col.append(rgb)
|
|
583
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
584
|
+
cmd.set_color("col" + str(j),col[j])
|
|
585
|
+
|
|
586
|
+
for j in range(nbins/2,nbins):
|
|
587
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
588
|
+
coldesc.append('col' + str(j))
|
|
589
|
+
# create colors in a gradient from white to red
|
|
590
|
+
rgb = [min(1.0, float(j)*2/(nbins-1)), min(1.0,float(nbins-j-1)*2/(nbins-1)), min(1.0, float(nbins-j-1)*2/(nbins-1))]
|
|
591
|
+
|
|
592
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
593
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
594
|
+
hsv[1] = hsv[1]*sat
|
|
595
|
+
hsv[2] = hsv[2]*value
|
|
596
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
597
|
+
|
|
598
|
+
col.append(rgb)
|
|
599
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
600
|
+
cmd.set_color("col" + str(j),col[j])
|
|
601
|
+
|
|
602
|
+
elif gradient == 'rwb':
|
|
603
|
+
col=[]
|
|
604
|
+
coldesc=[]
|
|
605
|
+
for j in range(nbins/2):
|
|
606
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
607
|
+
coldesc.append('col' + str(j))
|
|
608
|
+
# create colors in a gradient from red to white
|
|
609
|
+
rgb = [min(1.0, float(nbins-j-1)*2/(nbins-1)), min(1.0,float(j)*2/(nbins-1)), min(1.0, float(j)*2/(nbins-1))]
|
|
610
|
+
|
|
611
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
612
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
613
|
+
hsv[1] = hsv[1]*sat
|
|
614
|
+
hsv[2] = hsv[2]*value
|
|
615
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
616
|
+
|
|
617
|
+
col.append(rgb)
|
|
618
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
619
|
+
cmd.set_color("col" + str(j),col[j])
|
|
620
|
+
|
|
621
|
+
for j in range(nbins/2,nbins):
|
|
622
|
+
coldesc.append('col' + str(j))
|
|
623
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
624
|
+
# create colors in a gradient from white to blue
|
|
625
|
+
rgb = [min(1.0, float(nbins-j-1)*2/(nbins-1)), min(1.0,float(nbins-j-1)*2/(nbins-1)), min(1.0, float(j)*2/(nbins-1))]
|
|
626
|
+
|
|
627
|
+
# convert rgb to hsv, modify saturation and value and convert back to rgb
|
|
628
|
+
hsv = list(colorsys.rgb_to_hsv(rgb[0],rgb[1],rgb[2]))
|
|
629
|
+
hsv[1] = hsv[1]*sat
|
|
630
|
+
hsv[2] = hsv[2]*value
|
|
631
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
632
|
+
|
|
633
|
+
col.append(rgb)
|
|
634
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
635
|
+
cmd.set_color("col" + str(j),col[j])
|
|
636
|
+
|
|
637
|
+
elif gradient == 'gray' or gradient == 'grey':
|
|
638
|
+
# if it is "gray" then sat must be 0!
|
|
639
|
+
sat = 0.0
|
|
640
|
+
col=[]
|
|
641
|
+
coldesc=[]
|
|
642
|
+
for j in range(nbins):
|
|
643
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
644
|
+
coldesc.append('col' + str(j))
|
|
645
|
+
# create colors in a gradient of grays from "sat" to "value"
|
|
646
|
+
|
|
647
|
+
hsv = [0, 0, sat + (value-sat)*float(j)/(nbins-1)]
|
|
648
|
+
# hsv[1] = hsv[1]*sat
|
|
649
|
+
# hsv[2] = hsv[2]*value
|
|
650
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
651
|
+
|
|
652
|
+
col.append(rgb)
|
|
653
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
654
|
+
cmd.set_color("col" + str(j),col[j])
|
|
655
|
+
|
|
656
|
+
elif gradient == 'reversegray' or gradient == 'reversegrey':
|
|
657
|
+
# if it is "gray" then sat must be 0!
|
|
658
|
+
sat = 0.0
|
|
659
|
+
col=[]
|
|
660
|
+
coldesc=[]
|
|
661
|
+
for j in range(nbins):
|
|
662
|
+
# coldesc.append('col' + str(sel[j]) + str(j))
|
|
663
|
+
coldesc.append('col' + str(j))
|
|
664
|
+
# create colors in a gradient of grays from "sat" to "value"
|
|
665
|
+
|
|
666
|
+
hsv = [0, 0, value - (value-sat)*float(j)/(nbins-1)]
|
|
667
|
+
# hsv[1] = hsv[1]*sat
|
|
668
|
+
# hsv[2] = hsv[2]*value
|
|
669
|
+
rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
|
|
670
|
+
|
|
671
|
+
col.append(rgb)
|
|
672
|
+
# cmd.set_color("col" + str(sel[j]) + str(j),col[j])
|
|
673
|
+
cmd.set_color("col" + str(j),col[j])
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
# return the gradient as a list of colors named by their index (i.e. col0,col1,col2,col3,...)
|
|
677
|
+
return coldesc
|
|
678
|
+
|
|
679
|
+
# allow calling without parentheses: color_hist_b [selection=], [mode= ],[gradient= ],[nbins= ]
|
|
680
|
+
cmd.extend("color_b",color_b)
|
|
681
|
+
cmd.extend("color_q",color_q)
|
|
682
|
+
|