Converts the hexvalue used by tuya for colour representation into
        an HSV value.
        
        Args:
            hexvalue(string): The hex representation generated by BulbDevice._rgb_to_hexvalue()
343170
def _hexvalue_to_hsv(hexvalue):
        
        h = int(hexvalue[7:10], 16) / 360
        s = int(hexvalue[10:12], 16) / 255
        v = int(hexvalue[12:14], 16) / 255

        return (h, s, v)
813000
static Color decode( String value, String defaultValue ) {

		Color result;
		try {
			result = Color.decode( value );

		} catch( NumberFormatException e ) {
			Logger logger = Logger.getLogger( GraphUtils.class.getName());
			logger.severe( "The specified color " + value + " could not be parsed. Back to default value: " + defaultValue );
			Utils.logException( logger, e );
			result = Color.decode( defaultValue );
		}

		return result;
	}
887992
def to_hsv
      red, green, blue = *[r, g, b].collect {|x| x / 255.0}
      max = [red, green, blue].max
      min = [red, green, blue].min

      if min == max
        hue = 0
      elsif max == red
        hue = 60 * ((green - blue) / (max - min))
      elsif max == green
        hue = 60 * ((blue - red) / (max - min)) + 120
      elsif max == blue
        hue = 60 * ((red - green) / (max - min)) + 240
      end

      saturation = (max == 0) ? 0 : (max - min) / max
      [hue % 360, saturation, max]
    end
1231294
def hex2term(hexval: str, allow_short: bool = False) -> str:
    
    return rgb2term(*hex2rgb(hexval, allow_short=allow_short))
701809
def normalize_hex(hex_value):
    
    match = HEX_COLOR_RE.match(hex_value)
    if match is None:
        raise ValueError(
            u"'{}' is not a valid hexadecimal color value.".format(hex_value)
        )
    hex_digits = match.group(1)
    if len(hex_digits) == 3:
        hex_digits = u''.join(2 * s for s in hex_digits)
    return u'#{}'.format(hex_digits.lower())
1172086
function ( hex, parse ) {
            var hex = hex.replace( '#', '' ),
                result = {};
    
            if ( hex.length < 5 ) hex = hex.charAt(0) + hex.charAt(0) + hex.charAt(1) + hex.charAt(1) + hex.charAt(2) + hex.charAt(2);
    
            ( '#' + hex ).replace( this.REG_HEX, function ( str, va, vb, vc ) {
                var r = Number( '0x' + va ).toString( 10 ),
                    g = Number( '0x' + vb ).toString( 10 ),
                    b = Number( '0x' + vc ).toString( 10 );
    
                result = {r: Number(r), g: Number(g), b: Number(b), a: 1};
            });
    
            return parse? result : 'rgb(' + result.r + ', ' + result.g + ', ' + result.b + ')';
        }
477047
private static Colour  parseColour(String val) throws SVGParseException
   {
      if (val.charAt(0) == '#')
      {
         IntegerParser  ip = IntegerParser.parseHex(val, 1, val.length());
         if (ip == null) {
            throw new SVGParseException("Bad hex colour value: "+val);
         }
         int  pos = ip.getEndPos();
         int  h1, h2, h3, h4;
         switch (pos) {
            case 4:
               int threehex = ip.value();
               h1 = threehex & 0xf00;  // r
               h2 = threehex & 0x0f0;  // g
               h3 = threehex & 0x00f;  // b
               return new Colour(0xff000000|h1<<12|h1<<8|h2<<8|h2<<4|h3<<4|h3);
            case 5:
               int fourhex = ip.value();
               h1 = fourhex & 0xf000;  // r
               h2 = fourhex & 0x0f00;  // g
               h3 = fourhex & 0x00f0;  // b
               h4 = fourhex & 0x000f;  // alpha
               return new Colour(h4<<28|h4<<24 | h1<<8|h1<<4 | h2<<4|h2 | h3|h3>>4);
            case 7:
               return new Colour(0xff000000 | ip.value());
            case 9:
               return new Colour(ip.value() << 24 | ip.value() >>> 8);
            default:
               // Hex value had bad length for a colour
               throw new SVGParseException("Bad hex colour value: "+val);
         }
      }

      String   valLowerCase = val.toLowerCase(Locale.US);
      boolean  isRGBA = valLowerCase.startsWith("rgba(");
      if (isRGBA || valLowerCase.startsWith("rgb("))
      {
         TextScanner  scan = new TextScanner(val.substring(isRGBA ? 5 : 4));
         scan.skipWhitespace();

         float  red = scan.nextFloat();
         if (!Float.isNaN(red) && scan.consume('%'))
            red = (red * 256) / 100;

         float  green = scan.checkedNextFloat(red);
         if (!Float.isNaN(green) && scan.consume('%'))
            green = (green * 256) / 100;

         float  blue = scan.checkedNextFloat(green);
         if (!Float.isNaN(blue) && scan.consume('%'))
            blue = (blue * 256) / 100;

         if (isRGBA) {
            float  alpha = scan.checkedNextFloat(blue);
            scan.skipWhitespace();
            if (Float.isNaN(alpha) || !scan.consume(')'))
               throw new SVGParseException("Bad rgba() colour value: "+val);
            return new Colour( clamp255(alpha * 256)<<24 | clamp255(red)<<16 | clamp255(green)<<8 | clamp255(blue) );
         } else {
            scan.skipWhitespace();
            if (Float.isNaN(blue) || !scan.consume(')'))
               throw new SVGParseException("Bad rgb() colour value: "+val);
            return new Colour( 0xff000000 | clamp255(red)<<16 | clamp255(green)<<8 | clamp255(blue) );
         }
      }
      else
      {
         boolean  isHSLA = valLowerCase.startsWith("hsla(");
         if (isHSLA || valLowerCase.startsWith("hsl("))
         {
            TextScanner  scan = new TextScanner(val.substring(isHSLA ? 5 : 4));
            scan.skipWhitespace();

            float  hue = scan.nextFloat();

            float  saturation = scan.checkedNextFloat(hue);
            if (!Float.isNaN(saturation))
               scan.consume('%');

            float  lightness = scan.checkedNextFloat(saturation);
            if (!Float.isNaN(lightness))
               scan.consume('%');

            if (isHSLA) {
               float alpha = scan.checkedNextFloat(lightness);
               scan.skipWhitespace();
               if (Float.isNaN(alpha) || !scan.consume(')'))
                  throw new SVGParseException("Bad hsla() colour value: "+val);
               return new Colour( clamp255(alpha * 256)<<24 | hslToRgb(hue, saturation, lightness) );
            } else {
               scan.skipWhitespace();
               if (Float.isNaN(lightness) || !scan.consume(')'))
                  throw new SVGParseException("Bad hsl() colour value: "+val);
               return new Colour( 0xff000000 | hslToRgb(hue, saturation, lightness) );
            }
         }
      }

      // Must be a colour keyword
      return parseColourKeyword(valLowerCase);
   }
1205962
def colour_hsv(self):
        """"""
        hexvalue = self.status()[self.DPS][self.DPS_INDEX_COLOUR]
        return BulbDevice._hexvalue_to_hsv(hexvalue)
597799
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) {
                this.logger.log(this.get(this.TXT.ILLEGAL_HEX), "error");
                return false;
            }

            rgb = Color.hex2rgb(hex);

            this.logger.log(sub("Hex value set to {hex} ({rgb})", {
                    hex: hex, rgb: rgb
                }));

            this.setValue(rgb);
        }
895542
function _0xColorToHex(color, convertToStr) {
        var hexColor = tinycolor(color.replace("0x", "#"));
        hexColor._format = "0x";

        if (convertToStr) {
            return hexColor.toString();
        }
        return hexColor;
    }
1216132
def hex_from(val):
    
    if isinstance(val, integer_types):
        hex_str = '%x' % val
        if len(hex_str) % 2:
            hex_str = '0' + hex_str
        return hex_str

    return hexlify(val)
296516
def _rgb_to_hex(rgbs):
    """"""
    rgbs, n_dim = _check_color_dim(rgbs)
    return np.array(['#%02x%02x%02x' % tuple((255*rgb[:3]).astype(np.uint8))
                     for rgb in rgbs], '|U7')
380857
def xy_to_hex(self, x, y, bri=1):
        """"""
        r, g, b = self.color.get_rgb_from_xy_and_brightness(x, y, bri)
        return self.color.rgb_to_hex(r, g, b)
1168295
def _rgb_to_hsv(rgbs):
    """"""
    rgbs, n_dim = _check_color_dim(rgbs)
    hsvs = list()
    for rgb in rgbs:
        rgb = rgb[:3]  # don't use alpha here
        idx = np.argmax(rgb)
        val = rgb[idx]
        c = val - np.min(rgb)
        if c == 0:
            hue = 0
            sat = 0
        else:
            if idx == 0:  # R == max
                hue = ((rgb[1] - rgb[2]) / c) % 6
            elif idx == 1:  # G == max
                hue = (rgb[2] - rgb[0]) / c + 2
            else:  # B == max
                hue = (rgb[0] - rgb[1]) / c + 4
            hue *= 60
            sat = c / val
        hsv = [hue, sat, val]
        hsvs.append(hsv)
    hsvs = np.array(hsvs, dtype=np.float32)
    if n_dim == 4:
        hsvs = np.concatenate((hsvs, rgbs[:, 3]), axis=1)
    return hsvs
357447
public static PactDslJsonRootValue hexValue(String hexValue) {
    if (!hexValue.matches(HEXADECIMAL)) {
      throw new InvalidMatcherException(EXAMPLE + hexValue + "\" is not a hexadecimal value");
    }
    PactDslJsonRootValue value = new PactDslJsonRootValue();
    value.setValue(hexValue);
    value.setMatcher(value.regexp("[0-9a-fA-F]+"));
    return value;
  }
726621
def hex2termhex(hexval: str, allow_short: bool = False) -> str:
    
    return rgb2termhex(*hex2rgb(hexval, allow_short=allow_short))
28487
public static PactDslJsonRootValue hexValue() {
    PactDslJsonRootValue value = new PactDslJsonRootValue();
    value.generators.addGenerator(Category.BODY, "", new RandomHexadecimalGenerator(10));
    value.setValue("1234a");
    value.setMatcher(value.regexp("[0-9a-fA-F]+"));
    return value;
  }