@param Color $color

@return string
432871
public static function rgb(Color $color)
    {
        return sprintf(
            'rgb(%d, %d, %d)',
            $color->getRgb()['r'],
            $color->getRgb()['g'],
            $color->getRgb()['b']
        );
    }
1074940
public static function foreground($color)
    {
        list($red, $green, $blue) = str_split(substr($color, 1), 2);

        $red   = hexdec($red);
        $green = hexdec($green);
        $blue  = hexdec($blue);

        return ($red < 200 && $green < 100 && $blue < 200) ? self::WHITE : self::BLACK;
    }
232570
public function color($color){
        $style = array(
            'font' => array(
                'color' => array('rgb'=>$color)
            )
        );
        $this->engine->getActiveSheet()->getStyle("$this->x$this->y")->applyFromArray($style);
        return $this;
    }
823915
public function setColor($color)
    {
        if (null === $color) {
            return $this;
        }

        $this->color = $this->convertColor($color);

        return $this;
    }
84264
public function color($color)
    {
        if ($color !== null) {
            Checkers::checkColor($color, null);
        }
        $this->color = $color;
        return $this;
    }
1211014
public static function parseHex($color)
    {
        if (!preg_match('/^#[A-Fa-f0-9]{6}$/', $color)) {
            throw new WrongColorFormatException($color);
        }

        return new Color(
            hexdec(substr($color, 1, 2)),
            hexdec(substr($color, 3, 2)),
            hexdec(substr($color, 5, 2))
        );
    }
208334
protected function toHex($color)
	    {
	        $rgb = $this->getRGBComponents($color);

	        return sprintf('#%02X%02X%02X', $rgb[0], $rgb[1], $rgb[2]);
	    }
71568
public static function getInvertedColor($color)
    {
        // Prepare the color for later usage
        $color = trim($color);
        $withHash = Regex::startsWith($color, '#');

        /*
         * Verify and get valid value of color.
         * An exception will be thrown if the value is not a color.
         */
        $validColor = Regex::getValidColorHexValue($color);

        // Grab color's components
        $red = hexdec(substr($validColor, 0, 2));
        $green = hexdec(substr($validColor, 2, 2));
        $blue = hexdec(substr($validColor, 4, 2));

        // Calculate inverted color's components
        $redInverted = self::getValidColorComponent(255 - $red);
        $greenInverted = self::getValidColorComponent(255 - $green);
        $blueInverted = self::getValidColorComponent(255 - $blue);

        // Voila, here is the inverted color
        $invertedColor = sprintf('%s%s%s', $redInverted, $greenInverted, $blueInverted);

        if ($withHash) {
            return sprintf('#%s', $invertedColor);
        }

        return $invertedColor;
    }
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;
    }
20874
public function setFromRGBColor(RGBColor $color)
    {
        return $this->setRed($color->getRed())
                        ->setGreen($color->getGreen())
                        ->setBlue($color->getBlue())
                        ->setAlpha($color->getAlpha());
    }
347421
private static function getColorAsFullHexCode($color)
    {
        $color = ltrim($color, '#');

        if (strlen($color) == 3) {
            $color = str_repeat(substr($color, 0, 1), 2)
                   . str_repeat(substr($color, 1, 1), 2)
                   . str_repeat(substr($color, 2, 1), 2);
        }

        return strtoupper($color);
    }
108161
public static function name(Color $color): string
    {
        if (!self::hasName($color)) {
            throw new ColorException('No matching CSS color name found for ' . self::hex($color));
        }

        return X11Colors::$colors[$color->getHex()][0];
    }
112306
public function cut_color($color) {
		$replace_colors = & $this->parser->data['csstidy']['replace_colors'];

		// if it's a string, don't touch !
		if (strncmp($color, "'", 1) == 0 || strncmp($color, '"', 1) == 0)
			return $color;

		/* expressions complexes de type gradient */
		if (strpos($color, '(') !== false && strncmp($color, 'rgb(' ,4) != 0) {
			// on ne touche pas aux couleurs dans les expression ms, c'est trop sensible
			if (stripos($color, 'progid:') !== false)
				return $color;
			preg_match_all(",rgb\([^)]+\),i", $color, $matches, PREG_SET_ORDER);
			if (count($matches)) {
				foreach ($matches as $m) {
					$color = str_replace($m[0], $this->cut_color($m[0]), $color);
				}
			}
			preg_match_all(",#[0-9a-f]{6}(?=[^0-9a-f]),i", $color, $matches, PREG_SET_ORDER);
			if (count($matches)) {
				foreach ($matches as $m) {
					$color = str_replace($m[0],$this->cut_color($m[0]), $color);
				}
			}
			return $color;
		}

		// rgb(0,0,0) -> #000000 (or #000 in this case later)
		if (strncasecmp($color, 'rgb(', 4)==0) {
			$color_tmp = substr($color, 4, strlen($color) - 5);
			$color_tmp = explode(',', $color_tmp);
			for ($i = 0; $i < count($color_tmp); $i++) {
				$color_tmp[$i] = trim($color_tmp[$i]);
				if (substr($color_tmp[$i], -1) === '%') {
					$color_tmp[$i] = round((255 * $color_tmp[$i]) / 100);
				}
				if ($color_tmp[$i] > 255)
					$color_tmp[$i] = 255;
			}
			$color = '#';
			for ($i = 0; $i < 3; $i++) {
				if ($color_tmp[$i] < 16) {
					$color .= '0' . dechex($color_tmp[$i]);
				} else {
					$color .= dechex($color_tmp[$i]);
				}
			}
		}

		// Fix bad color names
		if (isset($replace_colors[strtolower($color)])) {
			$color = $replace_colors[strtolower($color)];
		}

		// #aabbcc -> #abc
		if (strlen($color) == 7) {
			$color_temp = strtolower($color);
			if ($color_temp{0} === '#' && $color_temp{1} == $color_temp{2} && $color_temp{3} == $color_temp{4} && $color_temp{5} == $color_temp{6}) {
				$color = '#' . $color{1} . $color{3} . $color{5};
			}
		}

		switch (strtolower($color)) {
			/* color name -> hex code */
			case 'black': return '#000';
			case 'fuchsia': return '#f0f';
			case 'white': return '#fff';
			case 'yellow': return '#ff0';

			/* hex code -> color name */
			case '#800000': return 'maroon';
			case '#ffa500': return 'orange';
			case '#808000': return 'olive';
			case '#800080': return 'purple';
			case '#008000': return 'green';
			case '#000080': return 'navy';
			case '#008080': return 'teal';
			case '#c0c0c0': return 'silver';
			case '#808080': return 'gray';
			case '#f00': return 'red';
		}

		return $color;
	}
646325
protected function getColor($im, $color) {
        if ($color === self::COLOR_BG) {
            return $this->colorBg->allocate($im);
        } else {
            return $this->colorFg->allocate($im);
        }
    }
143503
public static function materialColors(string $color = null)
    {
        $colors = Collection::make([
            'red'           => '#F44336',
            'pink'          => '#E91E63',
            'purple'        => '#9C27B0',
            'deep_purple'   => '#673AB7',
            'indigo'        => '#3F51B5',
            'blue'          => '#2196F3',
            'light_blue'    => '#03A9F4',
            'cyan'          => '#00BCD4',
            'teal'          => '#009688',
            'green'         => '#4CAF50',
            'light_green'   => '#8BC34A',
            'lime'          => '#CDDC39',
            'yellow'        => '#FFEB3B',
            'amber'         => '#FFC107',
            'orange'        => '#FF9800',
            'deep_orange'   => '#FF5722',
            'brown'         => '#795548',
            'grey'          => '#9E9E9E',
            'blue_grey'     => '#607D8B'
        ]);

        if (!$color) {
            return $colors;
        }

        return $colors->has($color) ? $colors->get($color) : $color;
    }
573998
public function getRgbByColor($color) {
		$result = imagecolorsforindex($this->image, $color);
		return array(
			$result['red'],
			$result['green'],
			$result['blue']
		);
	}
653731
protected static function intColorToLab($color)
    {
        return self::xyzToLab(
            self::srgbToXyz(
                self::rgbToSrgb(
                    [
                        'R' => ($color >> 16) & 0xFF,
                        'G' => ($color >> 8) & 0xFF,
                        'B' => $color & 0xFF,
                    ]
                )
            )
        );
    }