Retrieve a tuple of all known color names, basic and 'known names'.
421675
def get_all_names() -> Tuple[str]:
    
    names = list(basic_names)
    names.extend(name_data)
    return tuple(sorted(set(names)))
1184293
def as_namedtuple(self):
        
        d = self.as_dict()
        return namedtuple('ColorRegister', d.keys())(*d.values())
523826
def get_color(self, color):
        '''
        
        '''
        if color is None:
            color = self.counter
        if isinstance(color, str):
            color = CNAMES[color]
        self.counter = color + 1
        color %= len(COLORS)
        return color
661212
public static function getKnownColors()
    {
        $colors = array(
            static::BLACK  => static::BASH_BACKGROUND_BLACK,
            static::RED    => static::BASH_BACKGROUND_RED,
            static::GREEN  => static::BASH_BACKGROUND_GREEN,
            static::YELLOW => static::BASH_BACKGROUND_YELLOW,
            static::BLUE   => static::BASH_BACKGROUND_BLUE,
            static::PURPLE => static::BASH_BACKGROUND_PURPLE,
            static::CYAN   => static::BASH_BACKGROUND_CYAN,
            static::WHITE  => static::BASH_BACKGROUND_WHITE
        );

        return $colors;
    }
119448
def getcolors(spec, n, cmap=None, value=None):
    
    if cmap is not None and spec is not None:
        from matplotlib.colors import LinearSegmentedColormap
        from matplotlib.cm import get_cmap
        if isinstance(cmap, LinearSegmentedColormap):
            return cmap(value)[:, 0:3]
        if isinstance(cmap, str):
            return get_cmap(cmap, n)(value)[:, 0:3]
    if isinstance(spec, str):
        return [getcolor(spec) for i in range(n)]
    elif isinstance(spec, list) and isinstance(spec[0], str):
        return [getcolor(s) for s in spec]
    elif (isinstance(spec, list) or isinstance(spec, ndarray)) and asarray(spec).shape == (3,):
        return [spec for i in range(n)]
    else:
        return spec
941766
def from_name(clz, name):
        
        if isinstance(name, list) and "green" in name:
            name = "teal"
        assert name in COLOR_NAMES, 'Unknown color name'
        r, b, g = COLOR_NAMES[name]
        return clz(r, b, g)
214436
def get_color_names(self, format_string):
        
        names = set()
        # Tokenize the format string and process them
        for token in self.tokens(format_string):
            if token.group("command"):
                name = dict(parse_qsl(token.group("command"))).get("color")
                if (
                    not name
                    or name in COLOR_NAMES_EXCLUDED
                    or name in COLOR_NAMES
                    or name[0] == "#"
                ):
                    continue
                names.add(name)
        return names
454273
public static function GetColorNameList () {
		return [
			static::NAME_INDIAN_RED,
			static::NAME_LIGHT_CORAL,
			static::NAME_SALMON ,
			static::NAME_DARK_SALMON,
			static::NAME_LIGHT_SALMON,
			static::NAME_CRIMSON,
			static::NAME_RED,
			static::NAME_FIRE_BRICK ,
			static::NAME_DARK_RED,
			static::NAME_PINK,
			static::NAME_LIGHT_PINK ,
			static::NAME_HOT_PINK,
			static::NAME_DEEP_PINK,
			static::NAME_MEDIUM_VIOLET_RED,
			static::NAME_PALE_VIOLET_RED,
			static::NAME_LIGHT_SALMON,
			static::NAME_CORAL,
			static::NAME_TOMATO ,
			static::NAME_ORANGE_RED ,
			static::NAME_DARK_ORANGE,
			static::NAME_ORANGE ,
			static::NAME_GOLD,
			static::NAME_YELLOW ,
			static::NAME_LIGHT_YELLOW,
			static::NAME_LEMON_CHIFFON,
			static::NAME_LIGHT_GOLDENROD_YELLOW,
			static::NAME_PAPAYA_WHIP,
			static::NAME_MOCCASIN,
			static::NAME_PEACH_PUFF ,
			static::NAME_PALE_GOLDENROD ,
			static::NAME_KHAKI,
			static::NAME_DARK_KHAKI ,
			static::NAME_LAVENDER,
			static::NAME_THISTLE,
			static::NAME_PLUM,
			static::NAME_VIOLET ,
			static::NAME_ORCHID ,
			static::NAME_FUCHSIA,
			static::NAME_MAGENTA,
			static::NAME_MEDIUM_ORCHID,
			static::NAME_MEDIUM_PURPLE,
			static::NAME_AMETHYST,
			static::NAME_BLUE_VIOLET,
			static::NAME_DARK_VIOLET,
			static::NAME_DARK_ORCHID,
			static::NAME_DARK_MAGENTA,
			static::NAME_PURPLE ,
			static::NAME_INDIGO ,
			static::NAME_SLATE_BLUE ,
			static::NAME_DARK_SLATE_BLUE,
			static::NAME_MEDIUM_SLATE_BLUE,
			static::NAME_GREEN_YELLOW,
			static::NAME_CHARTREUSE ,
			static::NAME_LAWN_GREEN ,
			static::NAME_LIME,
			static::NAME_LIME_GREEN ,
			static::NAME_PALE_GREEN ,
			static::NAME_LIGHT_GREEN,
			static::NAME_MEDIUM_SPRING_GREEN,
			static::NAME_SPRING_GREEN,
			static::NAME_MEDIUM_SEA_GREEN,
			static::NAME_SEA_GREEN,
			static::NAME_FOREST_GREEN,
			static::NAME_GREEN,
			static::NAME_DARK_GREEN ,
			static::NAME_YELLOW_GREEN,
			static::NAME_OLIVE_DRAB ,
			static::NAME_OLIVE,
			static::NAME_DARK_OLIVE_GREEN,
			static::NAME_MEDIUM_AQUAMARINE,
			static::NAME_DARK_SEA_GREEN ,
			static::NAME_LIGHT_SEA_GREEN,
			static::NAME_DARK_CYAN,
			static::NAME_TEAL,
			static::NAME_AQUA,
			static::NAME_CYAN,
			static::NAME_LIGHT_CYAN ,
			static::NAME_PALE_TURQUOISE ,
			static::NAME_AQUAMARINE ,
			static::NAME_TURQUOISE,
			static::NAME_MEDIUM_TURQUOISE,
			static::NAME_DARK_TURQUOISE ,
			static::NAME_CADET_BLUE ,
			static::NAME_STEEL_BLUE ,
			static::NAME_LIGHT_STEEL_BLUE,
			static::NAME_POWDER_BLUE,
			static::NAME_LIGHT_BLUE ,
			static::NAME_SKY_BLUE,
			static::NAME_LIGHT_SKY_BLUE ,
			static::NAME_DEEP_SKY_BLUE,
			static::NAME_DODGER_BLUE,
			static::NAME_CORNFLOWER_BLUE,
			static::NAME_MEDIUM_SLATE_BLUE,
			static::NAME_ROYAL_BLUE ,
			static::NAME_BLUE,
			static::NAME_MEDIUM_BLUE,
			static::NAME_DARK_BLUE,
			static::NAME_NAVY,
			static::NAME_MIDNIGHT_BLUE,
			static::NAME_CORNSILK,
			static::NAME_BLANCHED_ALMOND,
			static::NAME_BISQUE ,
			static::NAME_NAVAJO_WHITE,
			static::NAME_WHEAT,
			static::NAME_BURLY_WOOD ,
			static::NAME_TAN,
			static::NAME_ROSY_BROWN ,
			static::NAME_SANDY_BROWN,
			static::NAME_GOLDENROD,
			static::NAME_DARK_GOLDENROD ,
			static::NAME_PERU,
			static::NAME_CHOCOLATE,
			static::NAME_SADDLE_BROWN,
			static::NAME_SIENNA ,
			static::NAME_BROWN,
			static::NAME_MAROON ,
			static::NAME_WHITE,
			static::NAME_SNOW,
			static::NAME_HONEYDEW,
			static::NAME_MINT_CREAM ,
			static::NAME_AZURE,
			static::NAME_ALICE_BLUE ,
			static::NAME_GHOST_WHITE,
			static::NAME_WHITE_SMOKE,
			static::NAME_SEASHELL,
			static::NAME_BEIGE,
			static::NAME_OLD_LACE,
			static::NAME_FLORAL_WHITE,
			static::NAME_IVORY,
			static::NAME_ANTIQUE_WHITE,
			static::NAME_LINEN,
			static::NAME_LAVENDER_BLUSH ,
			static::NAME_MISTY_ROSE ,
			static::NAME_GAINSBORO,
			static::NAME_LIGHT_GREY ,
			static::NAME_SILVER ,
			static::NAME_DARK_GRAY,
			static::NAME_GRAY,
			static::NAME_DIM_GRAY,
			static::NAME_LIGHT_SLATE_GRAY,
			static::NAME_SLATE_GRAY ,
			static::NAME_DARK_SLATE_GRAY,
			static::NAME_BLACK,
		];
	}
955818
def get_color_list(method_list):
    """"""
    color_list = []
    for method in method_list:
        color = tuple([random() for _ in range(3)])  # 随机颜色画线
        color_list.append(color)
    return color_list
1120960
def get_colors(num=16, cmap=plt.cm.Set1):
    ''''''
    colors = []
    for i in xrange(num):
        if analysis_params.bw:
            colors.append('k' if i % 2 == 0 else 'gray')
        else:
            i *= 256.
            if num > 1:
                i /= num - 1.
            else:
                i /= num
            colors.append(cmap(int(i)))
    return colors
1284934
def _short_color_list(self):
        """"""
        return [c for c in colors.get_colors() if not re.search(r'\d', c)]
672646
def _get_colors(self, color_set, alpha, off_color, custom_colors={}):
        
        import matplotlib as mpl
        import matplotlib.pyplot as plt
        color_list = [off_color] * len(self.hkl_list)
        color_proxy_on_wulff = []
        miller_on_wulff = []
        e_surf_on_wulff = [(i, e_surf)
                           for i, e_surf in enumerate(self.e_surf_list)
                           if self.on_wulff[i]]

        c_map = plt.get_cmap(color_set)
        e_surf_on_wulff.sort(key=lambda x: x[1], reverse=False)
        e_surf_on_wulff_list = [x[1] for x in e_surf_on_wulff]
        if len(e_surf_on_wulff) > 1:
            cnorm = mpl.colors.Normalize(vmin=min(e_surf_on_wulff_list),
                                         vmax=max(e_surf_on_wulff_list))
        else:
            # if there is only one hkl on wulff, choose the color of the median
            cnorm = mpl.colors.Normalize(vmin=min(e_surf_on_wulff_list) - 0.1,
                                         vmax=max(e_surf_on_wulff_list) + 0.1)
        scalar_map = mpl.cm.ScalarMappable(norm=cnorm, cmap=c_map)

        for i, e_surf in e_surf_on_wulff:
            color_list[i] = scalar_map.to_rgba(e_surf, alpha=alpha)
            if tuple(self.miller_list[i]) in custom_colors.keys():
                color_list[i] = custom_colors[tuple(self.miller_list[i])]
            color_proxy_on_wulff.append(
                plt.Rectangle((2, 2), 1, 1, fc=color_list[i], alpha=alpha))
            miller_on_wulff.append(self.input_miller_fig[i])
        scalar_map.set_array([x[1] for x in e_surf_on_wulff])
        color_proxy = [plt.Rectangle((2, 2), 1, 1, fc=x, alpha=alpha)
                       for x in color_list]

        return color_list, color_proxy, color_proxy_on_wulff, miller_on_wulff, \
            e_surf_on_wulff_list
347202
def get_color(self, refresh=False):
        
        if refresh:
            self.refresh_complex_value('CurrentColor')

        ci = self.get_color_index(['R', 'G', 'B'], refresh)
        cur = self.get_complex_value('CurrentColor')
        if ci is None or cur is None:
            return None

        try:
            val = [cur.split(',')[c] for c in ci]
            return [int(v.split('=')[1]) for v in val]
        except IndexError:
            return None
869549
def _get_color(self, r, g, b):
        
        clr = (r, g, b)
        return clr
315701
def rgb(self, color_tuple):
        """"""
        # Check bounds
        self.color = tuple(map(self._apply_float_bounds, color_tuple[:3]))

        # Include alpha if necessary
        if len(color_tuple) > 3:
            self.alpha = self._apply_float_bounds(color_tuple[3])
1099088
def help(cls):
        """"""
        print("for named colors use :")
        for c in sorted(list(cls.colors.items())):
            print("{:10} {}".format(*c))
425461
def get_visible_color(color):
    """"""
    if isinstance(color, (str, type(""))):
        try:
            return getattr(_Visible, str('{}'.format(color)))
        except AttributeError:
            raise ValueError("incorrect color: {!r}".format(color))
    elif isinstance(color, tuple):
        return (0x80 ^ color[0], 0x80 ^ color[1], 0x80 ^ color[2])
    elif isinstance(color, int):
        if 0 <= color <= 0x07:
            index = color
            return 0xFF if index == 0 else 0xE8
        elif 0x08 <= color <= 0x0F:
            index = color - 0x08
            return 0xFF if index == 0 else 0xE8
        elif 0x10 <= color <= 0xE7:
            index = color - 0x10
            if 0 <= index % 36 < 18:
                return 0xFF
            else:
                return 0x10
        elif 0xE8 <= color <= 0xFF:
            index = color - 0x0E8
            return 0xFF if 0 <= index < 12 else 0xE8
    else:
        raise ValueError("incorrect color: {!r}".format(color))