Calculates hexadecimal value of current color instance

@param  string $prefix

@return string
557170
public function getHex($prefix = '')
    {
        return sprintf('%s%02x%02x%02x', $prefix,
            $this->getRedValue(),
            $this->getGreenValue(),
            $this->getBlueValue()
        );
    }
1177655
protected function color(&$out)
    {
        $color = [Type::T_COLOR];
        $s     = $this->count;

        if ($this->match('(#([0-9a-f]+))', $m)) {
            $nofValues = strlen($m[2]);
            $hasAlpha  = $nofValues === 4 || $nofValues === 8;
            $channels  = $hasAlpha ? [4, 3, 2, 1] : [3, 2, 1];

            switch ($nofValues) {
                case 3:
                case 4:
                    $num = hexdec($m[2]);

                    foreach ($channels as $i) {
                        $t = $num & 0xf;
                        $color[$i] = $t << 4 | $t;
                        $num >>= 4;
                    }
                    break;

                case 6:
                case 8:
                    $num = hexdec($m[2]);

                    foreach ($channels as $i) {
                        $color[$i] = $num & 0xff;
                        $num >>= 8;
                    }
                    break;

                default:
                    $this->seek($s);

                    return false;
            }

            if ($hasAlpha) {
                if ($color[4] === 255) {
                    $color[4] = 1; // fully opaque
                } else {
                    $color[4] = round($color[4] / 255, 3);
                }
            }

            $out = $color;

            return true;
        }

        return false;
    }
13602
function stripPrefix($prefix)
    {
        $key = (string) $this;

        if (substr($key, 0, strlen($prefix)) == $prefix)
            $key = substr($key, strlen($prefix));

        return new self($key);
    }
648042
public function toRgbaString($prefix = 'rgba', $alphaPrecision = 2)
    {
        return $prefix  . '('
            . $this->r . ','
            . $this->g . ','
            . $this->b . ','
            . round(1 - $this->a / 0x100, $alphaPrecision) . ')';
    }
692514
protected function buildUrl(string $prefix): string
    {
        return $this->isSubUrl ? $prefix . $this->value : $this->value;
    }
150549
public static function Hex2Rgb( string $color )
   {

      if ( $color[ 0 ] == '#' )
      {
         $color = \substr( $color, 1 );
      }

      if ( \strlen( $color ) == 8 )
      {
         $color = \substr( $color, 2 );
      }

      if ( \strlen( $color ) == 6 )
      {
         $r = $color[ 0 ] . $color[ 1 ];
         $g = $color[ 2 ] . $color[ 3 ];
         $b = $color[ 4 ] . $color[ 5 ];
      }
      else if ( \strlen( $color ) == 3 )
      {
         $r = $color[ 0 ] . $color[ 0 ];
         $g = $color[ 1 ] . $color[ 1 ];
         $b = $color[ 2 ] . $color[ 2 ];
      }
      else if ( \strlen( $color ) == 2 )
      {
         $r = $color;
         $g = $color;
         $b = $color;
      }
      else
      {
         return false;
      }

      return [ \hexdec( $r ), \hexdec( $g ), \hexdec( $b ) ];

   }
582398
public function getHexColors($limit = null, $round = true) {

		$hex 	= [];
		$width 	= imagesx($this -> image);
		$height = imagesy($this -> image);
			
		for($y = 0; $y < $height; $y++) {

			for($x = 0; $x < $width; $x++) {

				$index = imagecolorat($this -> image, $x, $y);
				$color = imagecolorsforindex($this -> image, $index);
				
				if(true === $round) {

					foreach(['red', 'green', 'blue'] as $type) {

						$color[$type] = intval((($color[$type]) + 15) / 32) * 32;

						if($color[$type] >= 256){
							$color[$type] = 240;
						}
					}
				}

				$hex[] = substr('0' . dechex($color['red']), -2) . substr('0' . dechex($color['green']), -2) . substr('0' . dechex($color['blue']), -2);
			}
		}

		$hex = array_count_values($hex);

		natsort($hex);

		$hex = $limit ? array_slice(array_reverse($hex, true), 0, $limit, true) : array_reverse($hex, true);

		return $hex;
	}
1171668
public function encodeHex($dec, $prefix = true)
    {
        $this->preOpMethodParamsCheck(array($dec));

        $dec = ($this->Test($dec) != 'hex') ? strrev($this->encodeValue($this->absValue($dec), '16')) : $dec;

        return ($prefix === true) ? $this->addHexPrefix($dec) : $dec;
    }
614069
public static function setPrefix($prefix)
    {
        if (!empty($prefix) && is_string($prefix)) {
            self::$prefix = $prefix;
            return true;
        }

        return false;
    }
795813
public function getGMT($prefix = self::GMT)
    {
        //argument must be a string
        Argument::i()->test(1, 'string');

        list($hour, $minute, $sign) = $this->getUtcParts($this->offset);
        return $prefix.$sign.$hour.$minute;
    }
334301
public static function colorToHex($color)
    {
        $colors = array(
            'maroon'    => '800000',
            'red'       => 'FF0000',
            'orange'    => 'FFA500',
            'yellow'    => 'FFFF00',
            'olive'     => '808000',
            'purple'    => '800080',
            'fuchsia'   => 'FF00FF',
            'white'     => 'FFFFFF',
            'lime'      => '00FF00',
            'green'     => '008000',
            'navy'      => '000080',
            'blue'      => '0000FF',
            'aqua'      => '00FFFF',
            'teal'      => '008080',
            'black'     => '000000',
            'silver'    => 'C0C0C0',
            'gray'      => '808080',
        );
        if (array_key_exists($color, $colors)) {
            return $colors[$color];
        }
        
        $color_pattern = '/rgb\((.*?)\)/';
        preg_match($color_pattern, $color, $matches);
        if (is_array($matches) && count($matches) > 0) {
            $rgb = explode(',', $matches[1]);
            if (is_array($rgb) && count($rgb) === 3) {
                return self::RGBToHex($rgb[0], $rgb[1], $rgb[2]);
            }
        }
        
        return $color;
    }
927506
public function normalizeHex($hex)
	{
		if(preg_match('/^(#?[a-f0-9]{3}){1,2}$/i', $hex) === 0)
		{
			throw new InvalidArgumentException(vsprintf('Invalid HEX value [ %s ].', [$hex]));
		}

		return (strpos($hex, '#') !== 0) ? '#' . $hex : $hex;
	}
825254
public function getInvertedColor($color)
    {
        $color = str_replace('#', '', $this->hex6($color));

        if (strlen($color) != 6) {
            return '#000000';
        }

        $rgb = '';
        for ($x = 0; $x < 3; $x++) {
            $c = 255 - hexdec(substr($color, (2 * $x), 2));
            $c = ($c < 0) ? 0 : dechex($c);
            $rgb .= (strlen($c) < 2) ? '0'.$c : $c;
        }
        return '#'.$rgb;
    }
1204353
public function prefix($prefix = null)
    {
        if (null !== $prefix) {
            $this->prefix = substr(md5($prefix), 0, 10) . '_';
        }

        return $this->prefix;
    }
158147
public static function hex($hex)
    {
        // RGB Hex -> RGB
        static::hex2rgb($hex, $r, $g, $b);

        return static::rgb($r, $g, $b);
    }
368224
private static String getHexSingle(String hex, int colorIndex) {
		validateHex(hex);

		if (hex.startsWith("#")) {
			hex = hex.substring(1);
		}

		int colorCharacters = 1;
		int numColors = hex.length();
		if (numColors > 4) {
			colorCharacters++;
			numColors /= 2;
		}

		String color = null;
		if (colorIndex >= 0 || numColors > 3) {
			if (numColors > 3) {
				colorIndex++;
			}
			int startIndex = colorIndex;
			if (colorCharacters > 1) {
				startIndex *= 2;
			}
			color = hex.substring(startIndex, startIndex + colorCharacters);
			color = expandShorthandHexSingle(color);
		}

		return color;
	}
625417
public function setTablePrefix($prefix) {
        if ($prefix) {
            $prefix = trim($prefix, '_') . '_';
        }

        $this->tablePrefix = $prefix;

        return $this;
    }