Return user-created Go2Color object or create one.
978024
def _init_objcolor(self, node_opts, **kwu):
        """"""
        objgoea = node_opts.kws['dict'].get('objgoea', None)
        # kwu: go2color go2bordercolor dflt_bordercolor key2col
        return Go2Color(self.gosubdag, objgoea, **kwu)
1343177
def colorgamut(self):
        """"""
        try:
            light_spec = self.controlcapabilities
            gtup = tuple([XYPoint(*x) for x in light_spec['colorgamut']])
            color_gamut = GamutType(*gtup)
        except KeyError:
            color_gamut = None

        return color_gamut
1232413
def get_colors(self, prefix, len_):
        """"""

        def color(tupl):
            """Make a color css"""
            return ((
                '%s.color-{0}, %s.color-{0} a:visited {{\n'
                '  stroke: {1};\n'
                '  fill: {1};\n'
                '}}\n'
            ) % (prefix, prefix)).format(*tupl)

        def value_color(tupl):
            """Make a value color css"""
            return ((
                '%s .text-overlay .color-{0} text {{\n'
                '  fill: {1};\n'
                '}}\n'
            ) % (prefix, )).format(*tupl)

        def ci_color(tupl):
            """Make a value color css"""
            if not tupl[1]:
                return ''
            return (('%s .color-{0} .ci {{\n'
                     '  stroke: {1};\n'
                     '}}\n') % (prefix, )).format(*tupl)

        if len(self.colors) < len_:
            missing = len_ - len(self.colors)
            cycles = 1 + missing // len(self.colors)
            colors = []
            for i in range(0, cycles + 1):
                for color_ in self.colors:
                    colors.append(darken(color_, 33 * i / cycles))
                    if len(colors) >= len_:
                        break
                else:
                    continue
                break
        else:
            colors = self.colors[:len_]

        # Auto compute foreground value color when color is missing
        value_colors = []
        for i in range(len_):
            if i < len(self.value_colors) and self.value_colors[i] is not None:
                value_colors.append(self.value_colors[i])
            else:
                value_colors.append(
                    'white' if is_foreground_light(colors[i]) else 'black'
                )

        return '\n'.join(
            chain(
                map(color, enumerate(colors)),
                map(value_color, enumerate(value_colors)),
                map(ci_color, enumerate(self.ci_colors))
            )
        )
735346
def create_opengl_object(gl_gen_function, n=1):
    """"""
    handle = gl.GLuint(1)
    gl_gen_function(n, byref(handle))  # Create n Empty Objects
    if n > 1:
        return [handle.value + el for el in range(n)]  # Return list of handle values
    else:
        return handle.value
318278
function rgb(red, green, blue){
  switch (arguments.length) {
    case 1:
      utils.assertColor(red);
      var color = red.rgba;
      return new nodes.RGBA(
          color.r
        , color.g
        , color.b
        , 1);
    default:
      return rgba(
          red
        , green
        , blue
        , new nodes.Unit(1));
  }
}
980883
def _create_ansi_color_dict(color_cls):
    "  "
    return {
        'ansidefault':   color_cls.BLACK,
        'ansiblack':     color_cls.BLACK,
        'ansidarkgray':  color_cls.BLACK | color_cls.INTENSITY,
        'ansilightgray': color_cls.GRAY,
        'ansiwhite':     color_cls.GRAY | color_cls.INTENSITY,
        
        # Low intensity.
        'ansidarkred':     color_cls.RED,
        'ansidarkgreen':   color_cls.GREEN,
        'ansibrown':       color_cls.YELLOW,
        'ansidarkblue':    color_cls.BLUE,
        'ansipurple':      color_cls.MAGENTA,
        'ansiteal':        color_cls.CYAN,

        # High intensity.
        'ansired':        color_cls.RED | color_cls.INTENSITY,
        'ansigreen':      color_cls.GREEN | color_cls.INTENSITY,
        'ansiyellow':     color_cls.YELLOW | color_cls.INTENSITY,
        'ansiblue':       color_cls.BLUE | color_cls.INTENSITY,
        'ansifuchsia':    color_cls.MAGENTA | color_cls.INTENSITY,
        'ansiturquoise':  color_cls.CYAN | color_cls.INTENSITY,
    }
736762
def get_color(self, optname, precedence=0):
        ''
        r = self.colorcache.get(optname, None)
        if r is None:
            coloropt = options._get(optname)
            colornamestr = coloropt.value if coloropt else optname
            r = self.colorcache[optname] = self._colornames_to_attr(colornamestr, precedence)
        return r
101375
def _get_color(self, color):
        
        qcolor = QtGui.QColor()
        qcolor.setRgb(int(color[:2], base=16),
                      int(color[2:4], base=16),
                      int(color[4:6], base=16))
        return qcolor
959488
def get_go2color_inst(self, hdrgo):
        """"""
        go2color = self.go2color.copy()
        go2color[hdrgo] = self.hdrgo_dflt_color
        return go2color
397964
def color(cls, value):
        """"""
        index = bisect(cls.breakpoints, value)
        return colors.fg(cls.colors_[index])
365617
def _color(self, msg, color):
        """"""
        kwargs = {'fg': color}
        return click.style(msg, **kwargs) if self.colorize else msg
1084562
def _init_equiv(self):
        """"""
        gocolored_all = set(self.go2color)
        go2obj_usr = self.gosubdag.go2obj
        go2color_add = {}
        for gocolored_cur, color in self.go2color.items():
            # Ignore GOs in go2color that are not in the user set
            if gocolored_cur in go2obj_usr:
                goobj = go2obj_usr[gocolored_cur]
                goids_equiv = goobj.alt_ids.union([goobj.id])
                # mrk_alt = "*" if gocolored_cur != goobj.id else ""
                # print("COLORED({}) KEY({}){:1} ALL({})".format(
                #     gocolored_cur, goobj.id, mrk_alt, goids_equiv))
                # Loop through GO IDs which are not colored, but are equivalent to colored GO IDs.
                for goid_add in goids_equiv.difference(gocolored_all):
                    if goid_add in go2color_add:
                        print('**TBD: TWO DIFFERENT COLORS FOR EQUIV GO ID') # pylint: disable=superfluous-parens
                    go2color_add[goid_add] = color
        # print("ADDING {N} GO IDs TO go2color".format(N=len(go2color_add)))
        for goid, color in go2color_add.items():
            self.go2color[goid] = color
957201
def _create_color_buttons(self):
        """"""

        button_size = (30, 30)
        button_style = wx.NO_BORDER

        try:
            self.linecolor_choice = \
                csel.ColourSelect(self, -1, unichr(0x2500), (0, 0, 0),
                                  size=button_size, style=button_style)
        except UnicodeEncodeError:
            # ANSI wxPython installed
            self.linecolor_choice = \
                csel.ColourSelect(self, -1, "-", (0, 0, 0),
                                  size=button_size, style=button_style)

        self.bgcolor_choice = \
            csel.ColourSelect(self, -1, "", (255, 255, 255),
                              size=button_size, style=button_style)
        self.textcolor_choice = \
            csel.ColourSelect(self, -1, "A", (0, 0, 0),
                              size=button_size, style=button_style)

        self.linecolor_choice.SetToolTipString(_(u"Border line color"))
        self.bgcolor_choice.SetToolTipString(_(u"Cell background"))
        self.textcolor_choice.SetToolTipString(_(u"Text color"))

        self.AddControl(self.linecolor_choice)
        self.AddControl(self.bgcolor_choice)
        self.AddControl(self.textcolor_choice)

        self.linecolor_choice.Bind(csel.EVT_COLOURSELECT, self.OnLineColor)
        self.bgcolor_choice.Bind(csel.EVT_COLOURSELECT, self.OnBGColor)
        self.textcolor_choice.Bind(csel.EVT_COLOURSELECT, self.OnTextColor)
759706
function fromXYZ(x, y, z) {
    var color = create();
    setXYZ(color, x, y, z);
    return color;
}
1236090
def from_rgb(cls, r: int, g: int, b: int) -> 'ColorCode':
        
        c = cls()
        c._init_rgb(r, g, b)
        return c
1152415
def color_string(color, string):
    
    if not color_available:
        return string

    return color + string + colorama.Fore.RESET
471732
def get_go2color_users(self,
                           usrgo_color='#feffa3', # yellow
                           hdrusrgo_color='#d4ffea', # green
                           hdrgo_color='#eee6f6'): # purple
        """"""
        go2color = {}
        # Color user GO IDs
        for goid in self.usrgos:
            go2color[goid] = usrgo_color
        # Color header GO IDs. Headers which are also GO IDs get their own color.
        for goid_hdr in self.hdrgos_actual:
            go2color[goid_hdr] = hdrusrgo_color if goid_hdr in self.usrgos else hdrgo_color
        return go2color