Package igraph :: Module colors
[hide private]
[frames] | no frames]

Module colors

Color handling functions.


License: Copyright (C) 2006-2007 Gabor Csardi <csardi@rmki.kfki.hu>, Tamas Nepusz <ntamas@rmki.kfki.hu> MTA RMKI, Konkoly-Thege Miklos st. 29-33, Budapest 1121, Hungary This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Classes [hide private]
  AdvancedGradientPalette
Advanced gradient that consists of more than two base colors.
  GradientPalette
Base class for gradient palettes
  Palette
Base class of color palettes.
Functions [hide private]
 
_clamp(value, min, max)
Clamps the given value between min and max
 
color_name_to_rgb(color, palette=None)
Converts a color given in one of the supported color formats to R-G-B values.
Variables [hide private]
  __loader__ = <zipimporter object "/Library/Python/2.5/site-pac...
  known_colors = {'alice blue': (0.941176470588, 0.972549019608,...
  palettes = {'gray': <igraph.colors.GradientPalette object at 0...
Function Details [hide private]

color_name_to_rgb(color, palette=None)

 

Converts a color given in one of the supported color formats to R-G-B values.

Examples:

>>> color_name_to_rgb("red")
(1., 0., 0.)
>>> color_name_to_rgb("#ff8000")
(1., 0.50196078431372548, 0.)
>>> color_name_to_rgb("#08f")
(0., 0.53333333333333333, 1.)
>>> color_name_to_rgb("rgb(100%, 50%, 0%)")
(1., 0.5, 0.)
Parameters:
  • color - the color to be converted in one of the following formats:
    • CSS color specification: #rrggbb or #rgb or rgb(red, green, blue) where the red-green-blue components are given as hexadecimal numbers in the first two cases and as decimals (in the range of 0-255) or percentages (0-100) in the third case. Of course these are given as strings.
    • 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
    • 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 R-G-B values corresponding to the given color in a 3-tuple. Since these colors are primarily used by Cairo routines, the tuples contain floats in the range 0.0-1.0

Variables Details [hide private]

__loader__

Value:
<zipimporter object "/Library/Python/2.5/site-packages/python_igraph-0\
.5.1-py2.5-macosx-10.5-i386.egg/igraph/">

known_colors

Value:
{'alice blue': (0.941176470588, 0.972549019608, 1.0),
 'aliceblue': (0.941176470588, 0.972549019608, 1.0),
 'antique white': (0.980392156863, 0.921568627451, 0.843137254902),
 'antiquewhite': (0.980392156863, 0.921568627451, 0.843137254902),
 'antiquewhite1': (1.0, 0.937254901961, 0.858823529412),
 'antiquewhite2': (0.933333333333, 0.874509803922, 0.8),
 'antiquewhite3': (0.803921568627, 0.752941176471, 0.690196078431),
 'antiquewhite4': (0.545098039216, 0.513725490196, 0.470588235294),
...

palettes

Value:
{'gray': <igraph.colors.GradientPalette object at 0x25b6f0>,
 'red-blue': <igraph.colors.GradientPalette object at 0x25b750>}