vis_tools.Color module#
Color.py
This file contains a simple RGB color class that uses normalized channel values in the range of 0-1.
Classes:
Color - a simple RGB color object.
Usage:
color = Color(1.0, 0.5, 0.0) # Equivalent to #ff7f00 in CSS
- class vis_tools.Color.Color(r=0, g=0, b=0)[source]#
Bases:
object
Class that encapsulates an RGB color.
- Public members:
r (int): Red channel value in range(0, 255)
g int): Green channel value in range(0, 255)
b (int): Blue channel value in range(0, 255)
- to_rgba_array_str()[source]#
Returns the color as a string representation of an RGBA array.
This is used by CZMLWriter and other classes that need to emit colors into Javascript formats.
- Returns:
“[r, g, b, 255]” where r, g, and b are the channel values.
- Return type:
str
- to_rgba_array()[source]#
Returns the color as an RGBA array.
- Returns:
[r, g, b, 255] where r, g, and b are the channel values.
- Return type:
array
- static from_html_hash(html_color)[source]#
Returns an RGB from an HTML/CSS #rrggbb-format string.
- Returns:
an RGB initialized with the colors from html_color
- Return type:
obj
- Parameters:
html_color – A string in the format “#rrggbb” where rr, gg, and bb
hex. (are the channel values in) –
- static lerp(a, b, factor0to1)[source]#
Returns an interpolated color.
This function calculates a color that is between colors a and b using the factor0to1 argument to calculate the mix. If factor0to1 is zero, the resulting color is a. If factor0to1 is 1, the resulting color is b. For values of factor0to1 between 0 and 1, the resulting color is a linearly interpolated mix of colors a and b.
- Returns:
An RGB initialized with the interpolated color.
- Return type:
obj
- Parameters:
a (obj) – An RGB representing the start color.
b (obj) – An RGB representing the end color.
factor0to1 (float) – A value in range(0,1) specifying the desired mix
b. (between colors a and) –