Converts the specified *RGB(A)* value to *RGB(A)* components.

@param integer $rgb The *RGB(A)* color value to convert.

@return mixed[] The *RGB(A)* components.
@throws InvalidArgumentException If `$rgb` is not a *RGB(A)* color value.
8720
public static function rgbaValueToRgbaComponents($rgb)
    {
        self::throwExceptionIfNotRgbaValue($rgb);

        $alpha = self::rgbaValueToAlphaComponent($rgb);

        if (0 === $alpha) {
            $alpha = 0xFF;
        }

        return [
            'R' => self::rgbaValueToRedComponent($rgb),
            'G' => self::rgbaValueToGreenComponent($rgb),
            'B' => self::rgbaValueToBlueComponent($rgb),
            'A' => $alpha
        ];
    }
33641
public static function normalizeCssRgb(array $rgba)
    {
        foreach ($rgba as &$val) {
            if (strpos($val, '%') !== false) {
                $val = str_replace('%', '', $val);
                $val = round($val * 2.55);
            }
        }

        return $rgba;
    }
345073
public function getColorWithRGB($color) {
		if (func_num_args() == 1 && is_int($color)) {
			return $color;
		}
		if (is_string($color)) {
			$color = self::transformRGB($color);
		} elseif(func_num_args() == 3) {
			$color = func_get_args();
		}
		return imagecolorallocate($this->image, $color[0], $color[1], $color[2]);
	}
357608
public static function IsHexColorCode ($rgb) {
		return (($hex_array = static::ToHexStringArray($rgb)) !== false) ? ctype_xdigit($hex_array[0]) && ctype_xdigit($hex_array[1]) && ctype_xdigit($hex_array[2]) : false;
	}
51132
public function getAvgRgb(): array
    {
        $resource = imagescale($this->resource, 1, 1);

        $rgba = imagecolorsforindex($resource, imagecolorat($resource, 0, 0));

        imagedestroy($resource);

        return array_slice(array_values($rgba), 0, 3);
    }
506222
public static function rgb2xyz( $rgb )
	{
		list( $r, $g, $b ) = $rgb;
		$r	= $r / 255;
		$g	= $g / 255;
		$b	= $b / 255;
		$x	= 0.430574 * $r + 0.341550 * $g + 0.178325 * $b;
		$y	= 0.222015 * $r + 0.706655 * $g + 0.071330 * $b;
		$z	= 0.020183 * $r + 0.129553 * $g + 0.939180 * $b;
		return array( $x, $y, $z );
	}
1118462
public static function fromHex(string $color): Color
    {
        if (!Validator::isValidHex($color)) {
            throw new InvalidColorException('Invalid hex value');
        }

        return new self(...array_values(self::hexToRgb($color)));
    }
406829
public static function rgb_to_hsv( $color = array() ) {
		$var_r = ( $color[0] / 255 );
		$var_g = ( $color[1] / 255 );
		$var_b = ( $color[2] / 255 );
		$var_min = min( $var_r, $var_g, $var_b );
		$var_max = max( $var_r, $var_g, $var_b );
		$del_max = $var_max - $var_min;
		$h = 0;
		$s = 0;
		$v = $var_max;
		if ( 0 != $del_max ) {
			$s = $del_max / $var_max;
			$del_r = ( ( ( $var_max - $var_r ) / 6 ) + ( $del_max / 2 ) ) / $del_max;
			$del_g = ( ( ( $var_max - $var_g ) / 6 ) + ( $del_max / 2 ) ) / $del_max;
			$del_b = ( ( ( $var_max - $var_b ) / 6 ) + ( $del_max / 2 ) ) / $del_max;
			if ( $var_r == $var_max ) {
				$h = $del_b - $del_g;
			} elseif ( $var_g == $var_max ) {
				$h = ( 1 / 3 ) + $del_r - $del_b;
			} elseif ( $var_b == $var_max ) {
				$h = ( 2 / 3 ) + $del_g - $del_r;
			}
			if ( $h < 0 ) {
				$h++;
			}
			if ( $h > 1 ) {
				$h--;
			}
		}
		return array(
			'h' => round( $h, 2 ),
			's' => round( $s, 2 ),
			'v' => round( $v, 2 ),
		);
	}
441395
public static function fromValue($rgb, $hasalpha = true)
    {
        $color = new self();

        return $color->setFromValue($rgb, $hasalpha);
    }
573998
public function getRgbByColor($color) {
		$result = imagecolorsforindex($this->image, $color);
		return array(
			$result['red'],
			$result['green'],
			$result['blue']
		);
	}
603687
public function setColorLightness($value)
    {
        if (!is_array($value) ||
            !array_key_exists(0, $value) ||
            !array_key_exists(1, $value) ||
            !is_numeric($value[0]) ||
            !is_numeric($value[1]) ||
            $value[0] < 0 || $value[0] > 1 ||
            $value[1] < 0 || $value[1] > 1
        ) {
            throw new \InvalidArgumentException(
                "The value passed to setColorLightness was invalid. ".
                "Please check the documentation.");
        }
        
        $this->colorLightness = array((float)$value[0], (float)$value[1]);
        return $this;
    }
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;

   }
1150147
public function setFromArray(array $rgbArray)
    {
        if ( ! $this->checkRgbArray($rgbArray) )
            throw new Exceptions\InvalidRGBArrayException("The RGB Array must have the required keys : 'r', 'g', 'b'.");

        $this->setValues($rgbArray['r'], $rgbArray['g'], $rgbArray['b']);

        return $this;
    }
736236
static function resolveColor($color) {
        if(\is_int($color)) {
            return $color;
        }
        
        if(!\is_array($color)) {
            return \hexdec(((string) $color));
        }
        
        if(\count($color) < 1) {
            throw new \InvalidArgumentException('Color "'.\var_export($color, true).'" is not resolvable');
        }
        
        return (($color[0] << 16) + (($color[1] ?? 0) << 8) + ($color[2] ?? 0));
    }
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 );
	}
480837
public function color($color)
    {
        if ($color instanceof Collection) {
            $color = $color->toArray();
        }

        return $this->options([
            'color' => $color,
        ]);
    }
342383
public static function rgb2hsv( $rgb )
	{
#		return self::rgb2hsv_2( $rgb );
		list( $r, $g, $b ) = $rgb;
		$v	= max( $r, $g, $b );
		$t	= min( $r, $g, $b );
		$s	= ( $v == 0 ) ? 0 : ( $v - $t ) / $v;
		if( $s == 0 )
			$h	= 0;
		else
		{
			$a	= $v - $t;
			$cr	= ( $v - $r ) / $a;
			$cg	= ( $v - $g ) / $a;
			$cb	= ( $v - $b ) / $a;
			$h	= ( $r == $v ) ? $cb - $cg : ( ( $g == $v ) ? 2 + $cr - $cb : ( ( $b == $v ) ? $h = 4 + $cg - $cr : 0 ) );
			$h	= 60 * $h;
			$h	= ( $h < 0 ) ? $h + 360 : $h;
		}
		return array( round( $h ), round( $s * 100 ), round( $v / 2.55 ) );
	}