returns gdk.Color object of the given color
177232
def gdk(self, color):
        """"""
        c = self.parse(color)
        return gdk.Color.from_floats(c)
342481
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] == '#'
    # hex color
    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. for i in range(0, lc, 2)])
    return color
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
1326409
def color_(self, i=None):
        
        global palette, color_num
        if i is not None:
            color_num = i
        if color_num == len(palette) - 1:
            color_num = 0
        res = palette[color_num]
        color_num += 1
        return res
1317087
static Color getColorProperty(IChemObject object, String key) {
        Object value = object.getProperty(key);
        if (value instanceof Color) return (Color) value;
        if (value != null) throw new IllegalArgumentException(key + " property should be a java.awt.Color");
        return null;
    }
474550
def _get_colors(self):
        """"""
        try:
            csbi = _WindowsCSBI.get_info(self.win32_stream_handle)
            return csbi['fg_color'], csbi['bg_color']
        except IOError:
            return 7, 0
922557
def get_goid2color_pval(self):
        """"""
        go2color = {}
        self.set_goid2color_pval(go2color)
        color_dflt = self.alpha2col[1.000]
        for goid in self.go2res:
            if goid not in go2color:
                go2color[goid] = color_dflt
        return go2color
1326524
def get_color(self):
        """"""
        self.get_status()
        try:
            self.color = self.data['color']
            self.mode = self.data['mode']
        except TypeError:
            self.color = 0
            self.mode = ''

        return {'color': self.color, 'mode': self.mode}
1061140
def get_rgb_color(color):
    
    if color == INVERTED:
        foreground = (0, 255, 0)
        background = (0, 65, 0)
    elif color == NORMAL:
        foreground = (0, 65, 0)
        background = (0, 255, 0)
    else:
        foreground = (0, 0, 0)
        background = COLOR_INFO[color]
    return (foreground, background)
1353441
def create_color(color):
    
    if color[0] == "#":
        # Convert hex string to RGB
        return [int(color[i:i + 2], 16) / 255 for i in range(1, 7, 2)]
    else:
        # Create a named colors instance
        nc = vtk.vtkNamedColors()
        return nc.GetColor3d(color)
1195918
def rgb_color_picker(obj, min_luminance=None, max_luminance=None):
    """"""
    color_value = int.from_bytes(
        hashlib.md5(str(obj).encode('utf-8')).digest(),
        'little',
    ) % 0xffffff
    color = Color(f'#{color_value:06x}')
    if min_luminance and color.get_luminance() < min_luminance:
        color.set_luminance(min_luminance)
    elif max_luminance and color.get_luminance() > max_luminance:
        color.set_luminance(max_luminance)
    return color
770840
def read_colormap(fh, byteorder, dtype, count, offsetsize):
    """"""
    cmap = fh.read_array(byteorder+dtype[-1], count)
    cmap.shape = (3, -1)
    return cmap
1019929
def get_bgcolor(self, index):
        """"""
        if index.column() == 0:
            color = QColor(Qt.lightGray)
            color.setAlphaF(.05)
        elif index.column() < 3:
            color = QColor(Qt.lightGray)
            color.setAlphaF(.2)
        else:
            color = QColor(Qt.lightGray)
            color.setAlphaF(.3)
        return color
608687
private static Color getColor(String colorString) {

		Color color = null;

		String[] colorParts = colorString.split(",");

		try {

			switch (colorParts.length) {

			case 1:
				Field field = Color.class.getField(colorString);
				color = (Color) field.get(null);
				break;

			case 3:
				color = new Color(Integer.parseInt(colorParts[0]),
						Integer.parseInt(colorParts[1]),
						Integer.parseInt(colorParts[2]));
				break;

			case 4:
				color = new Color(Integer.parseInt(colorParts[0]),
						Integer.parseInt(colorParts[1]),
						Integer.parseInt(colorParts[2]),
						Integer.parseInt(colorParts[3]));
				break;

			default:
				throw new GeoPackageException("Unexpected color arguments: "
						+ colorParts.length + ", color: " + colorString);
			}

		} catch (Exception e) {
			throw new GeoPackageException("Invalid color: " + colorString
					+ ", Allowable Formats: colorName | r,g,b | r,g,b,a", e);
		}

		return color;
	}
991064
def color(self):
        """"""
        color = idc.GetColor(self.ea, idc.CIC_ITEM)
        if color == 0xFFFFFFFF:
            return None

        return color
467473
private void extractFgBgData(Map<Integer, Integer> colorHistogram) {
        if (colorHistogram.isEmpty()) {
            // An empty histogram indicates we've encountered a 0px area image. It has no luminance.
            mBackgroundLuminance = mForegroundLuminance = 0;
            mBackgroundColor = Color.BLACK;
            mForegroundColor = Color.BLACK;
        } else if (colorHistogram.size() == 1) {
            // Deal with views that only contain a single color
            final int singleColor = colorHistogram.keySet().iterator().next();
            mBackgroundLuminance = mForegroundLuminance =
                    ContrastUtils.calculateLuminance(singleColor);
            mForegroundColor = singleColor;
            mBackgroundColor = singleColor;
        } else {
            // Find the average luminance value within the set of luminances for
            // purposes of splitting luminance values into high-luminance and
            // low-luminance buckets. This is explicitly not a weighted average.
            double luminanceSum = 0;
            for (int color : colorHistogram.keySet()) {
                luminanceSum += ContrastUtils.calculateLuminance(color);
            }

            final double averageLuminance = luminanceSum / colorHistogram.size();

            // Select the highest and lowest luminance values that contribute to
            // most number of pixels in the image -- our background and
            // foreground colors.
            double lowLuminanceContributor = 0.0d;
            double highLuminanceContributor = 1.0d;
            int lowLuminanceColor = -1;
            int highLuminanceColor = -1;
            int maxLowLuminanceFrequency = 0;
            int maxHighLuminanceFrequency = 0;
            for (Entry<Integer, Integer> entry : colorHistogram.entrySet()) {
                final int color = entry.getKey();
                final double luminanceValue = ContrastUtils.calculateLuminance(color);
                final int frequency = entry.getValue();
                if ((luminanceValue < averageLuminance) && (frequency > maxLowLuminanceFrequency)) {
                    lowLuminanceContributor = luminanceValue;
                    maxLowLuminanceFrequency = frequency;
                    lowLuminanceColor = color;
                } else if ((luminanceValue >= averageLuminance)
                        && (frequency > maxHighLuminanceFrequency)) {
                    highLuminanceContributor = luminanceValue;
                    maxHighLuminanceFrequency = frequency;
                    highLuminanceColor = color;
                }
            }

            // Background luminance is that which occurs more frequently
            if (maxHighLuminanceFrequency > maxLowLuminanceFrequency) {
                mBackgroundLuminance = highLuminanceContributor;
                mBackgroundColor = highLuminanceColor;
                mForegroundLuminance = lowLuminanceContributor;
                mForegroundColor = lowLuminanceColor;
            } else {
                mBackgroundLuminance = lowLuminanceContributor;
                mBackgroundColor = lowLuminanceColor;
                mForegroundLuminance = highLuminanceContributor;
                mForegroundColor = highLuminanceColor;
            }
        }
    }
313901
function (r, g, b) {
            if (r > 255 || g > 255 || b > 255)
                throw "Invalid color component";
            return ((r << 16) | (g << 8) | b).toString(16);
        }