Change gradient color and change cursor position if an alpha value is supplied.

        :param color: new gradient color in RGB(A) format
        :type color: tuple[int]
483267
def set_color(self, color):
        
        if len(color) == 3:
            alpha = self.get()
        else:
            alpha = color[3]
        self._draw_gradient(alpha, color[:3])
114338
def background_color(self, value):
        

        if value is not None:
            assert type(value) is QColor, "'{0}' attribute: '{1}' type is not 'QColor'!".format(
                "background_color", value)
        self.__background_color = value
1016083
def setColor(self, color):
        ''''''
        if color == 'blue':
            self.color = 'blue'
            self.colorCode = self.colors['blue']
            self.colorCodeDark = self.colors['dblue']
        elif color == 'red':
            self.color = 'red'
            self.colorCode = self.colors['red']
            self.colorCodeDark = self.colors['dred']
        elif color == 'yellow':
            self.color = 'yellow'
            self.colorCode = self.colors['yellow']
            self.colorCodeDark = self.colors['dyellow']
        elif color == 'green':
            self.color = 'green'
            self.colorCode = self.colors['green']
            self.colorCodeDark = self.colors['dgreen']
        elif color == 'wild':  # No color modification
            self.wild = True
            self.color = 'wild'
            self.colorCodeDark = self.colors['dwild']
            self.colorCode = self.colors['wild']
95043
def _draw_gradient(self, alpha, color):
        """"""
        self.delete("gradient")
        self.delete("cursor")
        del self.gradient
        width = self.winfo_width()
        height = self.winfo_height()

        bg = create_checkered_image(width, height)
        r, g, b = color
        w = width - 1.
        gradient = Image.new("RGBA", (width, height))
        for i in range(width):
            for j in range(height):
                gradient.putpixel((i, j), (r, g, b, round2(i / w * 255)))
        self.gradient = ImageTk.PhotoImage(Image.alpha_composite(bg, gradient),
                                           master=self)

        self.create_image(0, 0, anchor="nw", tags="gardient",
                          image=self.gradient)
        self.lower("gradient")

        x = alpha / 255. * width
        h, s, v = rgb_to_hsv(r, g, b)
        if v < 50:
            fill = "gray80"
        else:
            fill = 'black'
        self.create_line(x, 0, x, height, width=2, tags='cursor', fill=fill)
451339
def setColor( self, color ):
        
        # sets the border color as the full value
        self.setBorderColor(color)
        
        # set the highlight color as the color with a 140 % alpha
        clr = QColor(color)
        clr.setAlpha(150)
        self.setHighlightColor(clr)
        
        # set the fill color as the color with a 50 % alpha
        clr = QColor(color)
        clr.setAlpha(80)
        self.setFillColor(clr)
936359
def setHighlightColor( self, color ):
        
        self._highlightColor = QColor(color)
        self.setAlternateHighlightColor(self._highlightColor.darker(110))
520948
def set(self, alpha):
        
        if alpha > 255:
            alpha = 255
        elif alpha < 0:
            alpha = 0
        x = alpha / 255. * self.winfo_width()
        self.coords('cursor', x, 0, x, self.winfo_height())
        self._variable.set(alpha)
212781
def _get_color(color):
        
        color = str(color).replace("#", "")
        qcolor = QtGui.QColor()
        qcolor.setRgb(int(color[:2], base=16),
                      int(color[2:4], base=16),
                      int(color[4:6], base=16))
        return qcolor
463731
def set_draw_color(self, r,g=-1,b=-1):
        ""
        if((r==0 and g==0 and b==0) or g==-1):
            self.draw_color=sprintf('%.3f G',r/255.0)
        else:
            self.draw_color=sprintf('%.3f %.3f %.3f RG',r/255.0,g/255.0,b/255.0)
        if(self.page>0):
            self._out(self.draw_color)
467452
def SetMarkerColor(self, color):
        
        self._markercolor = Color(color)
        if isinstance(self, ROOT.TAttMarker):
            ROOT.TAttMarker.SetMarkerColor(self, self._markercolor('root'))
416269
def setQuickColor( self, color ):
        
        colorset = XPaletteColorSet()
        colorset.setPalette(QPalette(color))
        self.setColorSet(colorset)
1075036
def color(self, color):
        
        if color is None:
            color = 0xFFFFFFFF

        idc.SetColor(self.ea, idc.CIC_FUNC, color)
901637
public static int getDeclinedColorFromColor(int color) {
        int bg = 0xffffffff;
        int a = DECLINED_EVENT_ALPHA;
        int r = (((color & 0x00ff0000) * a) + ((bg & 0x00ff0000) * (0xff - a))) & 0xff000000;
        int g = (((color & 0x0000ff00) * a) + ((bg & 0x0000ff00) * (0xff - a))) & 0x00ff0000;
        int b = (((color & 0x000000ff) * a) + ((bg & 0x000000ff) * (0xff - a))) & 0x0000ff00;
        return (0xff000000) | ((r | g | b) >> 8);
    }
248762
def hexcolor(color):
    " "
    # first, if this is a hex color already, return!
    # Python 3: needs rewrite for str/unicode change
    if isinstance(color, six.string_types):
        if color[0] == '#' and len(color)==7:
            return color.lower()

    # now, get color to an rgb tuple
    rgb = (0,0,0)
    if isinstance(color, tuple):
        rgb = color
    elif isinstance(color, list):
        rgb = tuple(color)
    elif isinstance(color, six.string_types):
        c = color.lower()
        if c.find(' ')>-1:    c = c.replace(' ','')
        if c.find('gray')>-1: c = c.replace('gray','grey')
        if c in x11_colors:
            rgb = x11_colors[c]
    else:
        try:
            rgb = color.Red(), color.Green(), color.Blue()
        except:
            pass

    # convert rgb to hex color
    col = '#%02x%02x%02x' % (rgb)
    return col.lower()
1346184
def setPenColor(self, color):
        
        color = QColor(color)
        if self._palette is None:
            self._palette = XNodePalette(self._scenePalette)
        
        self._palette.setColor(self._palette.NodeForeground, color)
        self.setDirty()
706385
def _change_sel_color(self, event):
        """"""
        (r, g, b), (h, s, v), color = self.square.get()
        self.red.set(r)
        self.green.set(g)
        self.blue.set(b)
        self.saturation.set(s)
        self.value.set(v)
        self.hexa.delete(0, "end")
        self.hexa.insert(0, color.upper())
        if self.alpha_channel:
            self.alphabar.set_color((r, g, b))
            self.hexa.insert('end',
                             ("%2.2x" % self.alpha.get()).upper())
        self._update_preview()
64739
function(color, alpha) {
            color = color.toRGB();
            alpha = Math.min(Math.max(alpha, 0), 1);
            var rgb = this.clone();

            rgb.red = (rgb.red * (1 - alpha)) + (color.red * alpha);
            rgb.green = (rgb.green * (1 - alpha)) + (color.green * alpha);
            rgb.blue = (rgb.blue * (1 - alpha)) + (color.blue * alpha);
            rgb.alpha = (rgb.alpha * (1 - alpha)) + (color.alpha * alpha);

            return rgb;
        }