:param color_hex: a hex string indicating the color of the porkfolio nose
        :return: nothing
        From the api...
        "the color of the nose is not in the desired_state
        but on the object itself."
325504
def set_state(self, color_hex):
        
        root_name = self.json_state.get('piggy_bank_id', self.name())
        response = self.api_interface.set_device_state(self, {
            "nose_color": color_hex
        }, root_name)
        self._update_state_from_response(response)
1221088
def normalize_hex(hex_color):
    
    hex_color = hex_color.replace('#', '').lower()
    length = len(hex_color)
    if length in (6, 8):
        return '#' + hex_color
    if length not in (3, 4):
        return None
    strhex = u'#%s%s%s' % (
        hex_color[0] * 2,
        hex_color[1] * 2,
        hex_color[2] * 2)
    if length == 4:
        strhex += hex_color[3] * 2
    return strhex
780973
def hex_colors(self):
        
        hc = []

        for color in self.colors:
            h = '#' + ''.join('{0:>02}'.format(hex(c)[2:].upper())
                              for c in color)
            hc.append(h)

        return hc
1013355
function setHex(color, hex) {
    hex = hex.replace(/^#/, "");
    var num = parseInt(hex, 16);

    color[0] = (num >> 16 & 255) / 255;
    color[1] = (num >> 8 & 255) / 255;
    color[2] = (num & 255) / 255;
    color[3] = 1

    return color;
}
480408
public boolean validateHexColor(String hexColor, DiagnosticChain diagnostics, Map<Object, Object> context) {
		boolean result = validateHexColor_Pattern(hexColor, diagnostics, context);
		return result;
	}
1308716
def set_color(self, rgb_tuple):
        
        if rgb_tuple is None:
            rgb_tuple = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get()
        clr = [c / 255.0 for c in rgb_tuple]
        self.figure.set_facecolor(clr)
        self.figure.set_edgecolor(clr)
        self.canvas.SetBackgroundColour(wx.Colour(*rgb_tuple))
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))
750825
def hex_to_rgb(color):
    
    color = normalize(color)
    color = color[1:]
    # return 'rgb'+str(tuple(ord(c) for c in color.decode('hex')))
    return 'rgb' + str((int(color[0:2], base=16), int(color[2:4], base=16), int(color[4:6], base=16)))
489238
def _hex_to_rgb(hex_code):
    
    if len(hex_code) != 6:
        raise ValueError(hex_code + " is not a string of length 6, cannot convert to rgb.")
    return tuple(map(ord, hex_code.decode("hex")))
335508
def hex_to_xy(self, h):
        
        rgb = self.color.hex_to_rgb(h)
        return self.rgb_to_xy(rgb[0], rgb[1], rgb[2])
1018108
def has_vertex_color(self):
        """"""
        for v in (self._vertex_colors, self._vertex_colors_indexed_by_faces,
                  self._vertex_colors_indexed_by_edges):
            if v is not None:
                return True
        return False
903511
def color(color_code) # :nodoc:
      if color_code and color_code =~ /^#[0-9a-fA-F]{6}$/
        # Convert a HTML style #RRGGBB color.
        color_code.sub(/^#/, '').upcase
      else
        index = Format.color(color_code)
        raise "Unknown color '#{color_code}' used in chart formatting." unless index
        palette_color(index)
      end
    end
390379
def _hex_to_rgb(color: str) -> Tuple[int, ...]:
        
        if color.startswith('#'):
            color = color.lstrip('#')
        return tuple(int(color[i:i + 2], 16) for i in (0, 2, 4))
805430
function nameToHex(color: string): string {
  if (typeof color !== 'string') return color
  const normalizedColorName = color.toLowerCase()
  return namedColorMap[normalizedColorName]
    ? `#${namedColorMap[normalizedColorName]}`
    : color
}
91869
def hex_to_rgb(hex_value):
    
    if '#' in hex_value:
        hex_value = hex_value.replace('#', '')
    if len(hex_value) < 6:
        return '0000/0000/0000'
    r = hex_value[:2]
    g = hex_value[2:4]
    b = hex_value[4:]
    return r + '00/' + g + '00/' + b + '00'
163631
def color_to_tuple(color, opacity=1):
    
    if(type(color) == str and color[0] == "#"):
        color = hex_color_to_tuple(color)

    elif type(color) == str:
        if color in color_dict:
            color = color_dict[color.lower()]
        else:
            print("无法解析颜色:" + color)
            color = (255, 125, 0, int(255*opacity)) 

    while len(color) < 4:
        color += (int(255*opacity),)

    return color
891557
private static function _get_hue( $hex ) {
		$red   = hexdec( substr( $hex, 0, 2 ) );
		$green = hexdec( substr( $hex, 2, 2 ) );
		$blue  = hexdec( substr( $hex, 4, 2 ) );

		if ( $red === $green && $red === $blue ) {
			return 0;
		}

		$hue = static::_get_hue_based_max_rgb( $red, $green, $blue );

		if ( 0 > $hue ) {
			$hue += 360;
		}

		return $hue;
	}