Set the colour if it is a valid colour.

@param $colour
967498
private function setColour($colour)
    {
        if (!in_array($colour, $this->getDefaultColours()) &&
            !preg_match(
                '_^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$_',
                $colour
            )
        ) {
            throw new InvalidColourException(
                sprintf(
                    'The colour "%s" is not a valid colour. Possible options are "%s" or a valid hex colour',
                    $colour,
                    implode('", "', $this->getDefaultColours())
                )
            );
        }

        $this->colour = $colour;
    }
823915
public function setColor($color)
    {
        if (null === $color) {
            return $this;
        }

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

        return $this;
    }
1148731
public function bg($color)
    {
        Assert::nullOrOneOf($color, self::$colors, 'The color must be null or one of the Style::* color constants. Got: "%s"');

        $this->bgColor = $color;

        return $this;
    }
346908
public function setUseColor(?bool $useColor): void
    {
        if (null === $useColor) {
            $useColor = $this->featureDetector->isSupported('stdout.ansi');
        }

        // @codeCoverageIgnoreStart
        if ($useColor) {
            $this->addStart = "\033[33m\033[2m{+\033[0m\033[33m\033[4m";
            $this->addEnd = "\033[0m\033[33m\033[2m+}\033[0m";
            $this->removeStart = "\033[36m\033[2m[-\033[0m\033[36m\033[4m";
            $this->removeEnd = "\033[0m\033[36m\033[2m-]\033[0m";
        } else {
            // @codeCoverageIgnoreEnd
            $this->addStart = '{+';
            $this->addEnd = '+}';
            $this->removeStart = '[-';
            $this->removeEnd = '-]';
        }
    }
588034
public function setThemeColor(string $themeColor): self
    {
        $this->isValidColor($themeColor);

        $this->themeColor = $themeColor;

        return $this;
    }
84264
public function color($color)
    {
        if ($color !== null) {
            Checkers::checkColor($color, null);
        }
        $this->color = $color;
        return $this;
    }
898717
protected function setColor(ColorInterface $color, bool $background = null): FormatterInterface
    {
        $name = $color->getName();
        $colors = $this->getColors();
        if (array_key_exists($name, $colors) === false) {
            throw new ColorNotSupported($color);
        }

        if ($background === true) {
            $this->background = $colors[$name] + 10;
        } else {
            $this->foreground = $colors[$name];
        }

        return $this;
    }
1074880
public function setBackgroundColor($backgroundColor)
    {
        if (null === $backgroundColor) {
            return $this;
        }

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

        return $this;
    }
1210200
public final void setColor(@ColorInt final int color) {
        if (this.color != color) {
            this.color = color;
            persistInt(color);
            notifyChanged();
            adaptPreviewView();
        }
    }
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)));
    }
831387
public function setColor($color)
	{
		if ( ! $this->isValidColor($color))
		{
			throw new \InvalidArgumentException('Invalid color format.');
		}
		
		$this->color = (string) $color;
		
		return $this;
	}
559726
protected function _prepColor($color) {
		if (strpos($color, '#') !== false) {
			return str_replace('#', '0x', $color);
		}
		if (is_numeric($color)) {
			return '0x' . $color;
		}
		return $color;
	}
29341
public function setForegroundColor($foregroundColor)
    {
        if ( is_null($this->frontColor) ) {
            $this->frontColor = new Color;
        }

        $this->frontColor->setFromArray($foregroundColor);

        return $this;
    }
1155768
public function setBackgroundColor(\Jdenticon\Color $color)
    {
        parent::setBackgroundColor($color);
        $this->canvas->backColor = $this->backgroundColor->toRgba();
    }
1058319
public void setColor(Color newColor) {
		if (newColor != null) {
			color.set(newColor);
		} else {
			color.set(DefaultColor);
		}
		colorF = color.toFloatBits();
		if (staticLight) dirty = true;
	}
193603
public function set_bg_color($color) {
        if (!isset($this->format['fill']['type'])) {
            $this->format['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID;
        }
        $this->format['fill']['color']['rgb'] = $this->parse_color($color);
    }
27765
public function setForegroundColor($code) {
        if ($code instanceof CINColor) {
            $this->colorFg = $code;
        } else {
            $this->colorFg = new CINColor($code);
        }
    }