def _string_to_rgb(color):
 if (not color.startswith('#')):
  if (color.lower() not in _color_dict):
   raise ValueError(('Color "%s" unknown' % color))
  color = _color_dict[color]
  assert (color[0] == '#')
 color = color[1:]
 lc = len(color)
 if (lc in (3, 4)):
  color = ''.join(((c + c) for c in color))
  lc = len(color)
 if (lc not in (6, 8)):
  raise ValueError('Hex color must have exactly six or eight elements following the # sign')
 color = np.array([(int(color[i:(i + 2)], 16) / 255.0) for i in range(0, lc, 2)])
 return color

def _string_to_rgb ( color ) : if ( not color . startswith ( '#' ) ) : if ( color . lower ( ) not in _color_dict ) : raise ValueError ( ( 'Color "%s" unknown' % color ) ) color = _color_dict [ color ] assert ( color [ 0 ] == '#' ) color = color [ 1 : ] lc = len ( color ) if ( lc in ( 3 , 4 ) ) : color = '' . join ( ( ( c + c ) for c in color ) ) lc = len ( color ) if ( lc not in ( 6 , 8 ) ) : raise ValueError ( 'Hex color must have exactly six or eight elements following the # sign' ) color = np . array ( [ ( int ( color [ i : ( i + 2 ) ] , 16 ) / 255.0 ) for i in range ( 0 , lc , 2 ) ] ) return color
convert user string or hex color to color array .