16进制的颜色值转换为Color对象，例如#fcf6d6

@param hex 16进制的颜色值，例如#fcf6d6
@return {@link Color}
@since 4.1.14
485726
public static Color hexToColor(String hex) {
		return getColor(Integer.parseInt(StrUtil.removePrefix("#", hex), 16));
	}
1251856
public static function hex2Rgb($hexColor)
    {
        $color = str_replace('#', '', $hexColor);
        if (strlen($color) > 3) {
            $rgb = array(
                'r' => hexdec(substr($color, 0, 2)),
                'g' => hexdec(substr($color, 2, 2)),
                'b' => hexdec(substr($color, 4, 2))
            );
        } else {
            $color = $hexColor;
            $r = substr($color, 0, 1) . substr($color, 0, 1);
            $g = substr($color, 1, 1) . substr($color, 1, 1);
            $b = substr($color, 2, 1) . substr($color, 2, 1);
            $rgb = array(
                'r' => hexdec($r),
                'g' => hexdec($g),
                'b' => hexdec($b)
            );
        }
        return $rgb;
    }
1119781
public static String shorthandHex(String color) {
		validateHex(color);
		if (color.length() > 5) {
			StringBuilder shorthandColor = new StringBuilder();
			int startIndex = 0;
			if (color.startsWith("#")) {
				shorthandColor.append("#");
				startIndex++;
			}
			for (; startIndex < color.length(); startIndex += 2) {
				String shorthand = shorthandHexSingle(color.substring(
						startIndex, startIndex + 2));
				if (shorthand.length() > 1) {
					shorthandColor = null;
					break;
				}
				shorthandColor.append(shorthand);
			}
			if (shorthandColor != null) {
				color = shorthandColor.toString();
			}
		}

		return color;
	}
762835
public String getColorString() {

        StringBuffer result = new StringBuffer();
        if (m_color == Simapi.COLOR_TRANSPARENT) {
            result.append(COLOR_TRANSPARENT);
        } else {
            if (m_color.getRed() < 16) {
                result.append('0');
            }
            result.append(Integer.toString(m_color.getRed(), 16));
            if (m_color.getGreen() < 16) {
                result.append('0');
            }
            result.append(Integer.toString(m_color.getGreen(), 16));
            if (m_color.getBlue() < 16) {
                result.append('0');
            }
            result.append(Integer.toString(m_color.getBlue(), 16));
        }
        return result.toString();
    }
878234
def hex_to_rgba(color):
    
    value = str(color).lstrip('#').strip()
    if len(value) == 6:
        rgb = [int(value[i:i + 2], 16) for i in (0, 2, 4)]
        rgba = np.append(rgb, 255).astype(np.uint8)
    else:
        raise ValueError('Only RGB supported')

    return rgba
1049547
def hex_color_to_tuple(hex):
    
    hex = hex[1:]
    length = len(hex) // 2
    return tuple(int(hex[i*2:i*2+2], 16) for i in range(length))
214647
public static Color toColor(final String colorString) {
        String trimmedString = colorString.trim();
        Color color = null;
        if (trimmedString.startsWith("#")) {
            final int shortHexCode = 4;
            if (trimmedString.length() == shortHexCode) {
                StringBuilder builder = new StringBuilder("#");
                for (int i = 1; i < trimmedString.length(); i++) {
                    builder.append(trimmedString.charAt(i));
                    builder.append(trimmedString.charAt(i));
                }
                color = SLD.toColor(builder.toString());
            } else {
                color = SLD.toColor(trimmedString);
            }
        }

        if (color == null) {
            color = parseRgbColor(trimmedString);
        }

        if (color == null) {
            color = parseRgbaColor(trimmedString);
        }

        if (color == null) {
            color = parseHslColor(trimmedString);
        }

        if (color == null) {
            color = parseHslaColor(trimmedString);
        }

        if (color == null) {
            final Field[] fields = Color.class.getFields();
            for (Field field: fields) {
                if (field.getType() == Color.class && Modifier.isFinal(field.getModifiers())
                        && Modifier.isStatic(field.getModifiers()) &&
                        field.getName().equalsIgnoreCase(trimmedString)) {
                    try {
                        return (Color) field.get(null);
                    } catch (IllegalAccessException e) {
                        throw new Error(e);
                    }
                }
            }
            color = Color.decode(trimmedString);
        }

        return color;
    }
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()
840674
public static String expandShorthandHex(String color) {
		validateHex(color);
		if (color.length() < 6) {
			StringBuilder expandColor = new StringBuilder();
			int startIndex = 0;
			if (color.startsWith("#")) {
				expandColor.append("#");
				startIndex++;
			}
			for (; startIndex < color.length(); startIndex++) {
				String expand = expandShorthandHexSingle(color.substring(
						startIndex, startIndex + 1));
				expandColor.append(expand);
			}
			color = expandColor.toString();
		}
		return color;
	}
162853
function getSingleColor(color)
{
    if (typeof color === 'number')
    {
        return hex2string(color);
    }
    else if ( typeof color === 'string' )
    {
        if ( color.indexOf('0x') === 0 )
        {
            color = color.replace('0x', '#');
        }
    }

    return color;
}
223571
function _hexToPHPColor($hex)
    {
        $length = strlen($hex);
        $dr = hexdec(substr($hex, $length - 6, 2));
        $dg = hexdec(substr($hex, $length - 4, 2));
        $db = hexdec(substr($hex, $length - 2, 2));
        $color = ($dr << 16) + ($dg << 8) + $db;
        return $color;
    }
1044617
private function convertColor($hex, $alpha = false)
    {
        $hex = str_replace('#', '', $hex);
        $length = strlen($hex);
        $rgb['0'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0));
        $rgb['1'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0));
        $rgb['2'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0));
        if ($alpha) {
            $rgb['2'] = $alpha;
        }

        return $rgb;
    }
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)
851085
def hex_to_rgb(hex_value):
    
    hex_value = normalize_hex(hex_value)
    hex_value = int(hex_value[1:], 16)
    return IntegerRGB(
        hex_value >> 16,
        hex_value >> 8 & 0xff,
        hex_value & 0xff
    )
1204225
function rgbaToHex(color) {
    color = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);

    var hex = (color && color.length === 4) ? "#" +
    ("0" + parseInt(color[1],10).toString(16)).slice(-2) +
    ("0" + parseInt(color[2],10).toString(16)).slice(-2) +
    ("0" + parseInt(color[3],10).toString(16)).slice(-2) : '';

    return hex.toUpperCase();
  }
892718
def hex_2_rgb(self, color):
        
        if not self.RE_HEX.match(color):
            color = "#FFF"
        if len(color) == 7:
            return (int(color[i : i + 2], 16) / 255 for i in [1, 3, 5])
        return (int(c, 16) / 15 for c in color)
673855
function() {
           
            var hex = this.get(this.OPT.HEX),
                l   = hex.length,
                c,i,rgb;

            // support #369 -> #336699 shorthand
            if (l === 3) {
                c = hex.split("");
                for (i=0; i<l; i=i+1) {
                    c[i] = c[i] + c[i];
                }

                hex = c.join("");
            }

            if (hex.length !== 6) {
                return false;
            }

            rgb = Color.hex2rgb(hex);


            this.setValue(rgb);
        }