Returns text with option to set the text colour.

@param 	$text <String>
@param 	$colour <String>
@param 	$backgroundColor <String>
@access 	public
@return 	<Mixed>
335907
public function getText(String $text=null, String $colour='green', String $backgroundColor='black')
	{
		$colours = [
			'green' => Attributes::COLOR_GREEN,
			'red' => Attributes::COLOR_RED,
			'yellow' => Attributes::COLOR_YELLOW,
			'blue' => Attributes::COLOR_BLUE,
			'cyan' => Attributes::COLOR_CYAN,
			'magenta' => Attributes::COLOR_MAGENTA,
			'white' => Attributes::COLOR_WHITE,
		];

		$backgroundColors = [
			'green' => Attributes::BG_GREEN,
			'red' => Attributes::BG_RED,
			'yellow' => Attributes::BG_YELLOW,
			'blue' => Attributes::BG_BLUE,
			'cyan' => Attributes::BG_CYAN,
			'magenta' => Attributes::BG_MAGENTA,
			'black' => Attributes::BG_BLACK,
		];

		if (isset($colours[$colour])) {
			$text = $colours[$colour] . $text;
		}

		$text = $backgroundColors[$backgroundColor] . $text; 

		return $text . "\n";
	}
739747
protected function getColoredString($string, $foreground_color = null,
                                        $background_color = null)
    {
        $colored_string = "";

        // Check if given foreground color found
        if (isset($this->foreground_colors[$foreground_color])) {
            $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m";
        }
        // Check if given background color found
        if (isset($this->background_colors[$background_color])) {
            $colored_string .= "\033[" . $this->background_colors[$background_color] . "m";
        }

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

        return $colored_string;
    }
520482
public function do_text(
        $text,
        $offsetX = 0,
        $offsetY = 0,
        $opacity = 1.0,
        $color = 0x000000,
        $size = 12,
        $font_file = null
    ) {
        $textColor = imagecolorallocatealpha($this->_image, ($color >> 16) & 0xFF, ($color >> 8) & 0xFF,
            $color & 0xFF, abs(1 - $opacity) * 127);
        if ($font_file) {
            imagettftext($this->_image, $size, 0, $offsetX, $offsetY, $textColor, $this->alias->resolve($font_file), $text);
        } else {
            imagestring($this->_image, $size, $offsetX, $offsetY, $text, $textColor);
        }

        return $this;
    }
930001
public function colorize($text, $options = 0, $width = 0)
    {
        $map = [
            self::AT_BOLD => "\033[1m",
            self::AT_ITALICS => "\033[3m",
            self::AT_UNDERLINE => "\033[4m",
            self::AT_BLINK => "\033[5m",
            self::AT_INVERSE => "\033[7m",

            self::BC_BLACK => "\033[40m",
            self::BC_RED => "\033[41m",
            self::BC_GREEN => "\033[42m",
            self::BC_YELLOW => "\033[43m",
            self::BC_BLUE => "\033[44m",
            self::BC_MAGENTA => "\033[45m",
            self::BC_CYAN => "\033[46m",
            self::BC_WHITE => "\033[47m",

            self::FC_BLACK => "\033[30m",
            self::FC_RED => "\033[31m",
            self::FC_GREEN => "\033[32m",
            self::FC_YELLOW => "\033[33m",
            self::FC_BLUE => "\033[34m",
            self::FC_MAGENTA => "\033[35m",
            self::FC_CYAN => "\033[36m",
            self::FC_WHITE => "\033[37m",
        ];

        if (!$this->isSupportColor()) {
            return $width ? str_pad($text, $width) : $text;
        }

        $c = '';
        for ($i = 0; $i < 32; $i++) {
            if ((1 << $i) & $options) {
                $c .= $map[(1 << $i) & $options];
            }
        }

        return $c . $text . "\033[0m" . str_repeat(' ', max($width - strlen($text), 0));
    }
579510
public function colour($string, $colour)
    {
        try {
            return $this->color->__invoke($string)
                ->apply($colour)
                ->__toString();
        } catch (NoStyleFoundException $e) {
            return $string;
        }
    }
589903
protected function drawCenteredText($text, $color)
    {
        $width = $this->image->getSize()->getWidth();
        $height = $this->image->getSize()->getHeight();
        $fontColor = $this->image->palette()->color('#' . $color);
        $fontSize = 48;
        $widthFactor = $width > 160 ? 0.8 : 0.9;
        $heightFactor = $height > 160 ? 0.8 : 0.9;
        do {
            $font = $this->getImagineService()
              ->font(__DIR__ . '/../../../data/font/Roboto-Regular.ttf', $fontSize, $fontColor);
            $fontBox = $font->box($text);
            $fontSize = round($fontSize * 0.8);
            
        } while ($fontSize > 5
          && ($width * $widthFactor < $fontBox->getWidth() || $height * $heightFactor < $fontBox->getHeight()));

        $pointX = max(0, floor(($width - $fontBox->getWidth()) / 2));
        $pointY = max(0, floor(($height - $fontBox->getHeight()) / 2));
        
        $this->image->draw()->text($text, $font, new Point($pointX, $pointY));
    }
396063
public function colorize(string $startColor, string $text, string $endColor = self::NORMAL): string
    {
        if ($this->getEnableColoredOutput()) {
            return $startColor . $text . $endColor;
        }

        return $text;
    }
1294797
public function apply($text)
    {
        $foreground = null;
        $background = null;

        if($this->foreground)
            $foreground = 'color: ' . $this->foreground . ';';

        if($this->background)
            $background = 'background: ' . $this->background . ';';

        $dom = '<span style="'.$foreground.$background.'">' . $text . '</span>';

        return $dom;
    }
1092014
public function colored($text, $color)
    {
        $colors = [
            'black'  => '0;30',
            'red'    => '0;31',
            'green'  => '0;32',
            'blue'   => '1;34',
            'yellow' => '1;33'
        ];

        $c = (
            array_key_exists($color, $colors)
            ? $colors[$color]
            : $colors['black']
        );

        if ($this->arguments->{'no-colors'}) {
            return $text;
        } else {
            return "\033[". $c . 'm' . $text . "\033[0m";
        }
    }
808507
public LienzoPanel setBackgroundColor(final String color)
    {
        if (null != color)
        {
            getElement().getStyle().setBackgroundColor(color);
        }
        return this;
    }
1253579
public TextCharacter withBackgroundColor(TextColor backgroundColor) {
        if(this.backgroundColor == backgroundColor || this.backgroundColor.equals(backgroundColor)) {
            return this;
        }
        return new TextCharacter(character, foregroundColor, backgroundColor, modifiers);
    }
1074880
public function setBackgroundColor($backgroundColor)
    {
        if (null === $backgroundColor) {
            return $this;
        }

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

        return $this;
    }
503634
public static function ask($text, $callback = null, $text_color = null, $bg_color = null)
    {
        if (null === $callback) {
            $callback = function() {
                return true;
            };
        }

        do {
            self::write($text, $text_color, $bg_color);
        } while (!$callback($answer = self::read()));

        return $answer;
    }
1032649
public static function color( $str, $color, $background = null ) 
	{	
		// ANSI escape codes are not available on Windows CMD
		// So we return the string unmodified
		if ( static::is_windows() ) 
		{
			return $str;
		}
		
		$out = "\033[".static::$colors[$color]."m";
		
		if ( !is_null( $background ) ) 
		{
			$out .= "\033[".static::$background_colors[$background]."m";
		}
		
		return $out.$str."\033[0m";
	}
1332126
public function setText($text)
    {
        if (!is_string($text)) {
            throw new InvalidArgumentException('string', 0);
        }

        $text = trim($text);

        if (strpos($text, '#') !== 0) {
            $text = '# ' . $text;
        }

        $this->text = $text;

        return $this;
    }
1299941
public function color($string = null, $color = null, $background = null) {
		$result = '';
		
		if ($color !== null) {
			$result = sprintf(self::COLOR_PATTERN, $this->_fontColors[$color]);
		}
		
		if ($background !== null) {
			$result .= sprintf(self::COLOR_PATTERN, $this->_backgroundColors[$background]);
		}
		
		return $result . $string . sprintf(self::COLOR_PATTERN, 0);
	}
1103567
public static function fromRgbString(string $string) : Colour
    {
        list($r, $g, $b) = ColourStringParser::parseRgbString($string);

        return new self($r, $g, $b);
    }