Provides the color corresponding to value `x` in the
        form of a tuple (R,G,B,A) with float values between 0. and 1.
178216
def rgba_floats_tuple(self, x):
        
        if x <= self.index[0]:
            return self.colors[0]
        if x >= self.index[-1]:
            return self.colors[-1]

        i = len([u for u in self.index if u < x])  # 0 < i < n.
        if self.index[i-1] < self.index[i]:
            p = (x - self.index[i-1])*1./(self.index[i]-self.index[i-1])
        elif self.index[i-1] == self.index[i]:
            p = 1.
        else:
            raise ValueError('Thresholds are not sorted.')

        return tuple((1.-p) * self.colors[i-1][j] + p*self.colors[i][j] for j
                     in range(4))
831897
def cmyk(self):
        """"""
        c, m, y = self.cmy
        k = min(c, m, y)

        # Handle division by zero in case of black = 1
        if k != 1:
            c = (c - k) / (1 - k)
            m = (m - k) / (1 - k)
            y = (y - k) / (1 - k)
        else:
            c, m, y = 1, 1, 1

        cmyk = (c, m, y, k)

        # Apply bound and return
        return tuple(map(lambda x: self._apply_float_bounds(x), cmyk))
581447
def black(m):
    

    m = float(m)

    def f(x):
        if x <= m:
            return 0.0
        return (x - m) / (1.0 - m)
    return f
115276
def get_color(self, value):
        
        if value in COLOR_SET:
            value = COLOR_MAP[value]
        else:
            try:
                value = int(value)
                if value >= 8:
                    raise ValueError()
            except ValueError as exc:
                raise ValueError(
                    'Colors should either a member of: {} or a positive '
                    'integer below 8'.format(', '.join(COLOR_NAMES))
                )
        return '{}{}'.format(self.PREFIX, value)
142011
def toColor(val, colormap):
    """"""
    for i in range(0, len(colormap) - 1):
        if colormap[i + 1][0] > val:
            scale = (val - colormap[i][0]) / \
                (colormap[i + 1][0] - colormap[i][0])
            r = colormap[i][1][0] + \
                (colormap[i + 1][1][0] - colormap[i][1][0]) * scale
            g = colormap[i][1][1] + \
                (colormap[i + 1][1][1] - colormap[i][1][1]) * scale
            b = colormap[i][1][2] + \
                (colormap[i + 1][1][2] - colormap[i][1][2]) * scale
            return "#" + toHex(r) + toHex(g) + toHex(b)
    return "#" + toHex(colormap[-1][1][0]) + toHex(colormap[-1][1][1]) + toHex(colormap[-1][1][2])
16547
public static Color interpolateColor( Color color1, Color color2, float fraction ) {
        float int2Float = 1f / 255f;
        fraction = Math.min(fraction, 1f);
        fraction = Math.max(fraction, 0f);

        float r1 = color1.getRed() * int2Float;
        float g1 = color1.getGreen() * int2Float;
        float b1 = color1.getBlue() * int2Float;
        float a1 = color1.getAlpha() * int2Float;

        float r2 = color2.getRed() * int2Float;
        float g2 = color2.getGreen() * int2Float;
        float b2 = color2.getBlue() * int2Float;
        float a2 = color2.getAlpha() * int2Float;

        float deltaR = r2 - r1;
        float deltaG = g2 - g1;
        float deltaB = b2 - b1;
        float deltaA = a2 - a1;

        float red = r1 + (deltaR * fraction);
        float green = g1 + (deltaG * fraction);
        float blue = b1 + (deltaB * fraction);
        float alpha = a1 + (deltaA * fraction);

        red = Math.min(red, 1f);
        red = Math.max(red, 0f);
        green = Math.min(green, 1f);
        green = Math.max(green, 0f);
        blue = Math.min(blue, 1f);
        blue = Math.max(blue, 0f);
        alpha = Math.min(alpha, 1f);
        alpha = Math.max(alpha, 0f);

        return new Color(red, green, blue, alpha);
    }
267276
function (str) {
            var values, r, g, b, a = 1;
            if ((str.length === 4 || str.length === 7) && str.substr(0, 1) === '#') {
                values = str.match(hexRe);
                if (values) {
                    r = parseHex(values[1]);
                    g = parseHex(values[2]);
                    b = parseHex(values[3]);
                    if (str.length === 4) {
                        r = paddingHex(r);
                        g = paddingHex(g);
                        b = paddingHex(b);
                    }
                }
            } else {
                values = str.match(rgbaRe);
                if (values) {
                    r = parseInt(values[1], 10);
                    g = parseInt(values[2], 10);
                    b = parseInt(values[3], 10);
                    a = parseFloat(values[4]) || 1;
                }
            }
            return typeof r === 'undefined' ? undefined : new Color({
                r: r,
                g: g,
                b: b,
                a: a
            });
        }
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))
1269064
def rgb_to_hsl(r, g, b):
    """"""
    r = r or 0
    g = g or 0
    b = b or 0
    r /= 255
    g /= 255
    b /= 255
    max_ = max((r, g, b))
    min_ = min((r, g, b))
    d = max_ - min_

    if not d:
        h = 0
    elif r is max_:
        h = 60 * (g - b) / d
    elif g is max_:
        h = 60 * (b - r) / d + 120
    else:
        h = 60 * (r - g) / d + 240

    l = .5 * (max_ + min_)
    if not d:
        s = 0
    elif l < 0.5:
        s = .5 * d / l
    else:
        s = .5 * d / (1 - l)
    return tuple(map(normalize_float, (h % 360, s * 100, l * 100)))
500236
def rgb(color,default=(0,0,0)):
    
    c = color.lower()
    if c[0:1] == '#' and len(c)==7:
        r,g,b = c[1:3], c[3:5], c[5:]
        r,g,b = [int(n, 16) for n in (r, g, b)]
        return (r,g,b)

    if c.find(' ')>-1:    c = c.replace(' ','')
    if c.find('gray')>-1: c = c.replace('gray','grey')
    if c in x11_colors.keys():  return x11_colors[c]
    return default
735124
def color_hex(self):
        """"""
        def clamp(x):
            return max(0, min(int(x), 255))

        r, g, b = np.trunc(self.color_rgb * 255)
        return "#{0:02x}{1:02x}{2:02x}".format(clamp(r), clamp(g), clamp(b))
885567
def FloatBetweenZeroAndOne(x):
    """"""
    x = float(x)
    if 0 <= x <= 1:
        return x
    else:
        raise ValueError("{0} not a float between 0 and 1.".format(x))
671595
def colors(self, value):
        
        if value is not None:
            assert type(value) is tuple, "'{0}' attribute: '{1}' type is not 'tuple'!".format("colors", value)
            assert len(value) == 2, "'{0}' attribute: '{1}' length should be '2'!".format("colors", value)
            for index in range(len(value)):
                assert type(
                    value[index]) is QColor, "'{0}' attribute element '{1}': '{2}' type is not 'QColor'!".format(
                    "colors", index, value)
        self.__colors = value
77046
function Color3(r, g, b) {
            if (r === void 0) { r = 0; }
            if (g === void 0) { g = 0; }
            if (b === void 0) { b = 0; }
            this.r = r;
            this.g = g;
            this.b = b;
        }
56690
def _hexvalue_to_rgb(hexvalue):
        
        r = int(hexvalue[0:2], 16)
        g = int(hexvalue[2:4], 16)
        b = int(hexvalue[4:6], 16)

        return (r, g, b)
295332
def hexbin(x, y, color="purple", **kwargs):
    
    if HAS_SEABORN:
        cmap = sns.light_palette(color, as_cmap=True)
    else:
        cmap = "Purples"
    plt.hexbin(x, y, cmap=cmap, **kwargs)
209171
public static void srgbToLab( float r , float g , float b , float lab[] ) {
		ColorXyz.srgbToXyz(r,g,b,lab);

		float X = lab[0];
		float Y = lab[1];
		float Z = lab[2];

		float xr = X/Xr_f;
		float yr = Y/Yr_f;
		float zr = Z/Zr_f;

		float fx, fy, fz;
		if(xr > epsilon_f)	fx = (float)Math.pow(xr, 1.0f/3.0f);
		else				fx = (kappa_f*xr + 16.0f)/116.0f;
		if(yr > epsilon_f)	fy = (float)Math.pow(yr, 1.0/3.0f);
		else				fy = (kappa_f*yr + 16.0f)/116.0f;
		if(zr > epsilon_f)	fz = (float)Math.pow(zr, 1.0/3.0f);
		else				fz = (kappa_f*zr + 16.0f)/116.0f;

		lab[0] = 116.0f*fy-16.0f;
		lab[1] = 500.0f*(fx-fy);
		lab[2] = 200.0f*(fy-fz);
	}