Gets the rgb value of a color.

@static
@access public
@param string  $color   The color.
@param boolean $implode Whether we want to implode the values or not.
@return array|string
345111
public static function get_rgb( $color, $implode = false ) {
		$obj = ariColor::newColor( $color );
		if ( $implode ) {
			return $obj->toCSS( 'rgb' );
		}
		return array( $obj->red, $obj->green, $obj->blue );
	}
1108132
public static function blue($color, $set = null)
    {
        $mode = '';
        $color = self::normalizeColor($color, $mode);
        if (null !== $set) {
            $newColor = [
                $color[0],
                $color[1],
                $set,
            ];
            if (self::hasAlpha($color)) {
                $newColor[3] = $color[3];
            }

            return self::resolveColor($newColor, $mode);
        }

        return $color[2];
    }
1045444
public function validateColor($color)
    {
        $request = new Request('GET', 'color');
        $response = $this->sendRequest($request, [
            'query' => [
                'string' => $color,
            ]
        ]);

        return $response->getBody();
    }
1367339
protected function fixPrecision($color)
    {
        if (strpos($color, ',') !== false) {
            $parts = explode(',', $color);
            $parts[3] = strpos($parts[3], '.') === false ? $parts[3] . '.0' : $parts[3];
            $color = implode(',', $parts);
        }
        return $color;
    }
12521
public function setColor($color)
    {
        $allowed_values = array('#ffffff', '#ffff01', '#ff6600', '#fe0000', '#9a0000', '#660066', '#0000fe', '#0099ff', '#01ffff', '#00ff33', '#349800', '#006634', '#666666', '#999999', '#e6e6e6', '#ffffcd', '#99ffff', '#ccff9a');
        if (!is_null($color) && (!in_array($color, $allowed_values))) {
            throw new \InvalidArgumentException("Invalid value for 'color', must be one of '#ffffff', '#ffff01', '#ff6600', '#fe0000', '#9a0000', '#660066', '#0000fe', '#0099ff', '#01ffff', '#00ff33', '#349800', '#006634', '#666666', '#999999', '#e6e6e6', '#ffffcd', '#99ffff', '#ccff9a'");
        }
        $this->container['color'] = $color;

        return $this;
    }
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;
    }
873793
public function getColoredString($string, $foregroundColor = null, $backgroundColor = null) {

        $colored_string = "";

        // Check if given foreground color found
        if (isset($this->foregroundColors[$foregroundColor])) {
            $colored_string .= "\033[" . $this->foregroundColors[$foregroundColor] . "m";
        }
        // Check if given background color found
        if (isset($this->backgroundColors[$backgroundColor])) {
            $colored_string .= "\033[" . $this->backgroundColors[$backgroundColor] . "m";
        }

        // Add string and end coloring
        $colored_string .=  $string . "\033[0m";

        return $colored_string;
    }
1227862
public static function Color2Rgb( $colorDefinition )
   {

      if ( \is_array( $colorDefinition ) )
      {
         if ( \count( $colorDefinition ) > 2 && \count( $colorDefinition ) < 5 )
         {
            return $colorDefinition;
         }
         throw new ArgumentError(
            'colorDefinition',
            $colorDefinition,
            'Drawing',
            'A (a)rgb(a) array with 3-4 Elements is required!'
         );
      }

      if ( static::IsHexFormat( $colorDefinition ) )
      {
         return static::Hex2Rgb( $colorDefinition );
      }

      $uc = \strtolower( $colorDefinition );

      if ( isset( static::$ColornameRGB[ $uc ] ) )
      {
         return static::$ColornameRGB[ $uc ];
      }

      if ( false !== ( $hex = static::Rgb2Hex( $colorDefinition ) ) )
      {
         return static::Hex2Rgb( $hex );
      }

      return false;

   }
1131545
public function getStyle()
	{
		$values = array();

		if ($this->fgColor)
		{
			$values[] = $this->fgColor;
		}

		if ($this->bgColor)
		{
			$values[] = $this->bgColor;
		}

		foreach ($this->options as $option)
		{
			$values[] = static::$knownOptions[$option];
		}

		return implode(';', $values);
	}
573998
public function getRgbByColor($color) {
		$result = imagecolorsforindex($this->image, $color);
		return array(
			$result['red'],
			$result['green'],
			$result['blue']
		);
	}
295597
function rgb($color) {
		if (is_string($color))
			$color=hexdec($color);
		$hex=str_pad($hex=dechex($color),$color<4096?3:6,'0',STR_PAD_LEFT);
		if (($len=strlen($hex))>6)
			user_error(sprintf(self::E_Color,'0x'.$hex),E_USER_ERROR);
		$color=str_split($hex,$len/3);
		foreach ($color as &$hue) {
			$hue=hexdec(str_repeat($hue,6/$len));
			unset($hue);
		}
		return $color;
	}
65537
protected static function getMixedColorAsRgb($color)
	{
		if (is_array($color)) {
			if (!static::validateRgbColor($color)) return false;
			return $color;
		} else {
			return static::hexToRgb($color);
		}
	}
346659
public function implodeKeys(string $glue = ''): string
    {
        return $this->implode_recursive($glue, $this->getArray(), true);
    }
561974
public function setColor($color)
	{
		if (is_array($color))
		{
			$this->color[0] = $color[0];
			$this->color[1] = $color[1];
			$this->color[2] = $color[2];
		}
		else
		{
			if (false !== strpos($color, '#'))
			{
				$color = substr($color, 1);
			}
			$this->color[0] = hexdec(substr($color, 0, 2));
			$this->color[1] = hexdec(substr($color, 2, 2));
			$this->color[2] = hexdec(substr($color, 4, 2));
		}

		return $this;
	}
1024089
public function setColor($color)
    {
        $allowedValues = $this->getColorAllowableValues();
        if (!is_null($color) && !in_array($color, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'color', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['color'] = $color;

        return $this;
    }
422531
public function getValue()
    {
        $out = [];
        foreach ($this->value as $key => $value) {
            $out[] = $key.'='.(is_array($value) ? implode(',', $value) : $value);
        }

        return strtoupper(implode(';', $out));
    }
653731
protected static function intColorToLab($color)
    {
        return self::xyzToLab(
            self::srgbToXyz(
                self::rgbToSrgb(
                    [
                        'R' => ($color >> 16) & 0xFF,
                        'G' => ($color >> 8) & 0xFF,
                        'B' => $color & 0xFF,
                    ]
                )
            )
        );
    }