schrodinger ::
structutils ::
color ::
ColorRamp ::
Class ColorRamp
|
|
Class ColorRamp
object --+
|
ColorRamp
An object for calculating colors on a customizable color ramp.
Examples
Coloring atoms according to a calculated property that ranges from 0
to 10:
color_ramp = ColorRamp(colors=("white", "blue"), values=(0,10))
for atom in st.atom:
property = calc_property(atom)
r, g, b = color_ramp.getRGB(property)
atom.setColorRGB(r, g, b)
Coloring atoms according to a calculated property that ranges from
-10 to 10 using blues for negative values and reds for positive
values:
color_ramp = ColorRamp(colors=("blue", "white", "red"),
values=(-10, 0, 10))
for atom in st.atom:
property = calc_property(atom)
color = color_ramp.getRGB(property)
atom.setColorRGB(*color)
|
__init__(self,
colors=( ' white ' , ' blue ' ) ,
values=( 0, 100) )
Initialize a ColorRamp object where the specified values correspond
to the given colors |
|
|
list
|
getRGB(self,
value)
Determine the color that corresponds to the specified value |
|
|
list
|
_getRGBFloat(self,
value)
Determine the color (in float format) that corresponds to the
specified value |
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
__init__(self,
colors=( ' white ' , ' blue ' ) ,
values=( 0, 100) )
(Constructor)
|
|
Initialize a ColorRamp object where the specified values correspond to
the given colors
- Parameters:
colors (list or tuple) - The list of colors. Any color description that is recognized by
Color may be used (a color name or colormap
index).
values (list or tuple) - The list of numerical values. This list must be the same length
as colors , all values must be unique, and the list
must be sorted in either ascending or descending order.
- Overrides:
object.__init__
|
Determine the color that corresponds to the specified value
- Parameters:
value (int or float) - The value to calculate the color for
- Returns: list
- The color corresponding to the specified value, where the color
is a represented by a list of (red, green, blue) integers in the
0-255 range.
|
_getRGBFloat(self,
value)
|
|
Determine the color (in float format) that corresponds to the
specified value
- Parameters:
value (int or float) - The value to calculate the color for
- Returns: list
- The color corresponding to the specified value, where the color
is a represented by a list of (red, green, blue) floats in the
0.0-1.0 range.
|