# ``igraph`.`drawing`.`colors``

module documentation
(source)

Color handling functions.

Class | `AdvancedGradientPalette` | Advanced gradient that consists of more than two base colors.
Class | `ClusterColoringPalette` | A palette suitable for coloring vertices when plotting a clustering.
Class | `GradientPalette` | Base class for gradient palettes
Class | `Palette` | Base class of color palettes.
Class | `PrecalculatedPalette` | A palette that returns colors from a pre-calculated list of colors
Class | `RainbowPalette` | A palette that varies the hue of the colors along a scale.
Function | `clamp` | Clamps the given value between min and max
Function | `color_name_to_rgb` | Converts a color given in one of the supported color formats to R-G-B values.
Function | `color_name_to_rgba` | Converts a color given in one of the supported color formats to R-G-B-A values.
Function | `color_to_html_format` | 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_to_rgb` | Converts a color given by its HSL coordinates (hue, saturation, lightness) to RGB coordinates.
Function | `hsla_to_rgba` | Converts a color given by its HSLA coordinates (hue, saturation, lightness, alpha) to RGBA coordinates.
Function | `hsv_to_rgb` | Converts a color given by its HSV coordinates (hue, saturation, value) to RGB coordinates.
Function | `hsva_to_rgba` | 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_to_hsl` | Converts a color given by its RGB coordinates to HSL coordinates (hue, saturation, lightness).
Function | `rgb_to_hsv` | Converts a color given by its RGB coordinates to HSV coordinates (hue, saturation, value).
Function | `rgba_to_hsla` | Converts a color given by its RGBA coordinates to HSLA coordinates (hue, saturation, lightness, alpha).
Function | `rgba_to_hsva` | Converts a color given by its RGBA coordinates to HSVA coordinates (hue, saturation, value, alpha).
Variable | `default_edge_colors` | Undocumented
Variable | `known_colors` | Undocumented
Variable | `palettes` | Undocumented

def clamp(value, min_value, max_value): (source)

Clamps the given value between min and max

def color_name_to_rgb(color, palette=None): (source)

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.

def color_name_to_rgba(color, palette=None): (source)

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:

- CSS3 color specification: `#rrggbb`, `#rgb`, `#rrggbbaa`, `#rgba`, `rgb(red, green, blue)`, `rgba(red, green, blue, alpha)`, `hsl(hue, saturation, lightness)`, `hsla(hue, saturation, lightness, alpha)`, `hsv(hue, saturation, value)` and `hsva(hue, saturation, value, alpha)` where the components are given as hexadecimal numbers in the first four cases and as decimals or percentages (0%-100%) in the remaining cases. Red, green and blue components are between 0 and 255; hue is between 0 and 360; saturation, lightness and value is between 0 and 100; alpha is between 0 and 1.
- Valid HTML color names, i.e. those that are present in the HTML 4.0 specification
- Valid X11 color names, see http://en.wikipedia.org/wiki/X11_color_names
- Red-green-blue components given separately in either a comma-, slash- or whitespace-separated string or a list or a tuple, in the range of 0-255. An alpha value of 255 (maximal opacity) will be assumed.
- Red-green-blue-alpha components given separately in either a comma-, slash- or whitespace-separated string or a list or a tuple, in the range of 0-255
- A single palette index given either as a string or a number. Uses the palette given in the `palette` parameter of the method call.

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

def color_to_html_format(color): (source)

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.

def darken(color, ratio=0.5): (source)

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.

def hsl_to_rgb(h, s, l): (source)

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].

def hsla_to_rgba(h, s, l, alpha=1.0): (source)

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].

def hsv_to_rgb(h, s, v): (source)

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].

def hsva_to_rgba(h, s, v, alpha=1.0): (source)

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].

def lighten(color, ratio=0.5): (source)

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.

def rgb_to_hsl(r, g, b): (source)

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].

def rgb_to_hsv(r, g, b): (source)

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].

def rgba_to_hsla(r, g, b, alpha=1.0): (source)

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].

def rgba_to_hsva(r, g, b, alpha=1.0): (source)

Converts a color given by its RGBA coordinates to HSVA coordinates (hue, saturation, value, alpha).

Each of the RGBA coordinates must be in the range [0, 1].

default_edge_colors: `dict` = (source)

Undocumented

known_colors: `dict` = (source)

Undocumented

palettes = (source)

Undocumented