Sets the foreground color.

@param string $color One of the color constants.

@return static The current instance.
518850
public function fg($color)
    {
        Assert::nullOrOneOf($color, self::$colors, 'The color must be null or one of the Style::* color constants. Got: "%s"');

        $this->fgColor = $color;

        return $this;
    }
1101836
public function setPixelColor($x, $y, Color $color) {
		imagesetpixel($this->image, $x, $y, $color->rgb);
		return $this;
	}
9109
public function setColor($color) {

        // if null is passed in, then just leave everything null
        if (!is_null($color)) {

            // if it an instance of another color
            if ($color instanceof ColorInterface) {

                // save the name
                $this->name = $color->getName();

                // save the xterm code
                $this->XTermCode = $color->getXTermCode();

                // save the RGB
                $this->RGB = $color->getRGB();

                // save the ansi code
                $this->ANSICode = $color->getANSICode();

                // if it is string, then it is a color name (maybe)
            } else if (is_string($color)) {

                if (Colors::isValidColorName($color)) {

                    $this->name = Colors::stripName($color);

                    // get the code for that name
                    $this->XTermCode = Colors::getXTermCode($this->name);

                    // save the RGB
                    $this->RGB = Colors::getRGB($this->name);

                    // get the ANSI code
                    $this->ANSICode = Colors::getANSICode($this->name);

                }

                // if it is an integer, then it is likely a xterm code
            } else if (is_int($color)) {

                // if it is between 0 and 255
                if ($color >= 0 && $color <= 255) {

                    // save this code
                    $this->XTermCode = $color;

                    // get the RGB for it
                    $this->name = Colors::getColorIndexForXTermCode($this->XTermCode);

                    // get the RGB
                    $this->RGB = Colors::getRGB($this->name);

                    // get the ANSI Code
                    $this->ANSICode = Colors::getANSICode($this->name);
                }

                // if it is an RGB array
            } else if (is_array($color)) {

                // there must be three items in the array
                if (count($color) === 3) {

                    // save the RGB
                    $this->RGB = $color;

                    // match this RGB to some code
                    $this->name = Colors::matchRGB($this->RGB);

                    // get the nearest ANSI Code
                    $this->ANSICode = Colors::getANSICode($this->name);

                    // get the nearest XTerm code
                    $this->XTermCode = Colors::getXTermCode($this->name);

                }
            }

        // null was passed in
        } else {

            // set the color to be empty
            $this->setEmpty();
        }
    }
1350686
public function setBackground($color = null)
    {
        if (null === $color) {
            $this->background = null;
            return;
        }
        if (!isset(static::$availableBackgroundColors[$color])) {
            throw new \InvalidArgumentException(sprintf(
                'Invalid background color specified: "%s". Expected one of (%s)',
                $color,
                implode(', ', array_keys(static::$availableBackgroundColors))
            ));
        }
        $this->background = static::$availableBackgroundColors[$color];
    }
977944
public function setBackgroundColor(int $color) : void
    {
        $background = $this->info(true)->backgroundImage;

        $this->set([
            'backgroundImage' => [
                'color' => sprintf('%06X', $color),
                'sourceUrl' => $background->sourceUrl ?? ''
            ]
        ]);
    }
1356886
public function setFGColor($level, ForegroundColors $color)
    {
        if (static::$foregroundColorMap === null) {
            $this->resetFGColors();
        }
        $this->checkLevel($level);
        static::$foregroundColorMap[$level] = $color;
        return $this;
    }
831387
public function setColor($color)
	{
		if ( ! $this->isValidColor($color))
		{
			throw new \InvalidArgumentException('Invalid color format.');
		}
		
		$this->color = (string) $color;
		
		return $this;
	}
1074880
public function setBackgroundColor($backgroundColor)
    {
        if (null === $backgroundColor) {
            return $this;
        }

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

        return $this;
    }
588034
public function setThemeColor(string $themeColor): self
    {
        $this->isValidColor($themeColor);

        $this->themeColor = $themeColor;

        return $this;
    }
234356
protected function assignTextStyle(string $color)
    {
        if (in_array($color, $this->supported_text_styles) === true) {
            $this->text_color = $color;
        }
    }
461417
public function setBGColor($level, ForegroundColors $color)
    {
        if (static::$foregroundColorMap === null) {
            $this->resetBGColor();
        }
        $this->checkLevel($level);
        static::$foregroundColorMap[$level] = $color;
        return $this;
    }
821273
public function setColour($colour)
    {
        if (!preg_match('/^[a-f0-9]{6}$/i', $colour)) {
            throw new \InvalidArgumentException(sprintf('Value %s must be a valid hex colour', $colour));
        }

        $this->colour = $colour;

        return $this;
    }
273268
function set_color($colour) {
    $col = $this->munge_colour($colour);

    if ( is_null($col) )
      $col = self::$_defaults["color"];

    //see __set and __get, on all assignments clear cache, not needed on direct set through __set
    $this->_prop_cache["color"] = null;
    if (is_array($col))
      $this->_props["color"] = $col["hex"];
  }
359874
public function setBackgroundColor($red, $green, $blue)
    {
        $this->red = $red;
        $this->green = $green;
        $this->blue = $blue;

        return $this;
    }
145500
public function setTransparent($color) {
	    $color = call_user_func_array([$this, 'getColorWithRGB'], func_get_args());
	    return imagecolortransparent($this->image, $color);
    }
9746
public function setBackgroundColor($backgroundColor)
    {
        $this->_backgroundColor = $backgroundColor;
        if ($this->_backgroundColor && $this->_colorTable) {
            $this->_colorTable->add($this->_backgroundColor);
        }
    }
168109
public /*internal*/ function setBackgroundColor($backgroundColor) {
        $this->backgroundColor = $backgroundColor;
        $this->font->setBackgroundColor($this->backgroundColor);
    }