colors.py
Go to the documentation of this file.
00001 import colorsys
00002 
00003 
00004 def get_color_for_string(name):
00005     hue = float(name.__hash__() % 0xFFFFFFFFFFFF) / 0xFFFFFFFFFFFF
00006     # choose colors with high saturation and value
00007     (r, g, b) = colorsys.hsv_to_rgb(hue, 1, 0.8)
00008     # convert floats into hexadecimal
00009     (r, g, b) = (int(r * 0xFF), int(g * 0xFF), int(b * 0xFF))
00010     # build a hex string like #a3bbc0
00011     code = '#%s%s%s' % (hex(r)[-2:], hex(g)[-2:], hex(b)[-2:])
00012     # single digit hexes yield 'x4''
00013     return code.replace('x', '0')


qt_dotgraph
Author(s): Thibault Kruse
autogenerated on Fri Jan 3 2014 11:44:08