def GLColor(color): """Convert a color to an OpenGL RGB color. The output is a tuple of three RGB float values ranging from 0.0 to 1.0. The input can be any of the following: - a string specifying the Xwindow name of the color - a QColor - a tuple or list of 3 int values 0..255 - a tuple or list of 3 float values 0.0..1.0 Any other input may give unpredictable results. """ if type(color) == str: color = QColor(color) if isinstance(color,QColor): color = (color.red(),color.green(),color.blue()) if len(color) == 3: if type(color[0]) == int: color = [ c/255. for c in color ] if type(color[0]) == float: return tuple(color) raise RuntimeError,"GLColor: unexpected input %s" % color