Color handling functions.
Class |
|
Advanced gradient that consists of more than two base colors. |
Class |
|
A palette suitable for coloring vertices when plotting a clustering. |
Class |
|
Base class for gradient palettes |
Class |
|
Base class of color palettes. |
Class |
|
A palette that returns colors from a pre-calculated list of colors |
Class |
|
A palette that varies the hue of the colors along a scale. |
Function | clamp |
Clamps the given value between min and max |
Function | color |
Converts a color given in one of the supported color formats to R-G-B values. |
Function | color |
Converts a color given in one of the supported color formats to R-G-B-A values. |
Function | color |
Formats a color given as a 3-tuple or 4-tuple in HTML format. |
Function | darken |
Creates a darker version of a color given by an RGB triplet. |
Function | hsl |
Converts a color given by its HSL coordinates (hue, saturation, lightness) to RGB coordinates. |
Function | hsla |
Converts a color given by its HSLA coordinates (hue, saturation, lightness, alpha) to RGBA coordinates. |
Function | hsv |
Converts a color given by its HSV coordinates (hue, saturation, value) to RGB coordinates. |
Function | hsva |
Converts a color given by its HSVA coordinates (hue, saturation, value, alpha) to RGB coordinates. |
Function | lighten |
Creates a lighter version of a color given by an RGB triplet. |
Function | rgb |
Converts a color given by its RGB coordinates to HSL coordinates (hue, saturation, lightness). |
Function | rgb |
Converts a color given by its RGB coordinates to HSV coordinates (hue, saturation, value). |
Function | rgba |
Converts a color given by its RGBA coordinates to HSLA coordinates (hue, saturation, lightness, alpha). |
Function | rgba |
Converts a color given by its RGBA coordinates to HSVA coordinates (hue, saturation, value, alpha). |
Variable | known |
Undocumented |
Variable | palettes |
Undocumented |
Converts a color given in one of the supported color formats to R-G-B values.
This is done by calling color_name_to_rgba
and then throwing away the alpha value.
See Also | |
color_name_to_rgba for more details about what formats are understood by this function. |
Converts a color given in one of the supported color formats to R-G-B-A values.
Examples:
>>> color_name_to_rgba("red") (1.0, 0.0, 0.0, 1.0) >>> color_name_to_rgba("#ff8000") == (1.0, 128/255.0, 0.0, 1.0) True >>> color_name_to_rgba("#ff800080") == (1.0, 128/255.0, 0.0, 128/255.0) True >>> color_name_to_rgba("#08f") == (0.0, 136/255.0, 1.0, 1.0) True >>> color_name_to_rgba("rgb(100%, 50%, 0%)") (1.0, 0.5, 0.0, 1.0) >>> color_name_to_rgba("rgba(100%, 50%, 0%, 25%)") (1.0, 0.5, 0.0, 0.25) >>> color_name_to_rgba("hsla(120, 100%, 50%, 0.5)") (0.0, 1.0, 0.0, 0.5) >>> color_name_to_rgba("hsl(60, 100%, 50%)") (1.0, 1.0, 0.0, 1.0) >>> color_name_to_rgba("hsv(60, 100%, 100%)") (1.0, 1.0, 0.0, 1.0)
Parameters | |
color | the color to be converted in one of the following formats:
|
palette | the palette to be used if a single number is passed to the method. Must be an instance of colors.Palette . |
Returns | |
the RGBA values corresponding to the given color in a 4-tuple. Since these colors are primarily used by Cairo routines, the tuples contain floats in the range 0.0-1.0 |
Formats a color given as a 3-tuple or 4-tuple in HTML format.
The HTML format is simply given by #rrggbbaa, where rr gives the red component in hexadecimal format, gg gives the green component bb gives the blue component and gg gives the alpha level. The alpha level is optional.
Creates a darker version of a color given by an RGB triplet.
This is done by mixing the original color with black using the given ratio. A ratio of 1.0 will yield a completely black color, a ratio of 0.0 will yield the original color. The alpha values are left intact.
Converts a color given by its HSL coordinates (hue, saturation, lightness) to RGB coordinates.
Each of the HSL coordinates must be in the range [0, 1].
Converts a color given by its HSLA coordinates (hue, saturation, lightness, alpha) to RGBA coordinates.
Each of the HSLA coordinates must be in the range [0, 1].
Converts a color given by its HSV coordinates (hue, saturation, value) to RGB coordinates.
Each of the HSV coordinates must be in the range [0, 1].
Converts a color given by its HSVA coordinates (hue, saturation, value, alpha) to RGB coordinates.
Each of the HSVA coordinates must be in the range [0, 1].
Creates a lighter version of a color given by an RGB triplet.
This is done by mixing the original color with white using the given ratio. A ratio of 1.0 will yield a completely white color, a ratio of 0.0 will yield the original color.
Converts a color given by its RGB coordinates to HSL coordinates (hue, saturation, lightness).
Each of the RGB coordinates must be in the range [0, 1].
Converts a color given by its RGB coordinates to HSV coordinates (hue, saturation, value).
Each of the RGB coordinates must be in the range [0, 1].
Converts a color given by its RGBA coordinates to HSLA coordinates (hue, saturation, lightness, alpha).
Each of the RGBA coordinates must be in the range [0, 1].