Generate the image

@param   string   $string
@param   integer  $size
@param   string   $color
@return  void
347578
private function generateImage($string, $size, $color)
	{
		$this->setString($string);
		$this->setSize($size);

		if ($this->fontPath === null)
		{
			$this->setFontPath(__DIR__ . '/fonts/OpenSans-Regular.ttf');
		}

		// Prepare the image
		$image = imagecreatetruecolor($this->pixelRatio * 5, $this->pixelRatio * 5);
		$background = imagecolorallocate($image, 0, 0, 0);

		// Prepage the color
		if (null !== $color)
		{
			$this->setColor($color);
		}
		$color = imagecolorallocate($image, $this->color[0], $this->color[1], $this->color[2]);
		imagefilledrectangle($image, 0, 0, $this->size, $this->size, $color);

		// Allocate A Color For The Text
		$white = imagecolorallocate($image, 255, 255, 255);

		$rnd = ceil($this->size / 20);

		$fontsize = round($this->size * 0.4); //ceil(($this->size / 3) + $rnd);

		$tb = imagettfbbox($fontsize, 0, $this->getFontPath(), $string);

		// Calculate x baseline
		/*if ($tb[0] >= -1)
		{
			$tb['x'] = abs($tb[0] + 1) * -1;
		}
		else
		{
			$tb['x'] = abs($tb[0] + 2);
		}

		// Calculate actual text width
		$tb['width'] = abs($tb[2] - $tb[0]);
		if ($tb[0] < -1)
		{
			$tb['width'] = abs($tb[2]) + abs($tb[0]) - 1;
		}

		// Calculate y baseline
		$tb['y'] = abs($tb[5] + 1);

		// Calculate actual text height
		$tb['height'] = abs($tb[7]) - abs($tb[1]);
		if ($tb[3] > 0)
		{
			$tb['height'] = abs($tb[7] - $tb[1]) - 1;
		}*/

		// Horizontally centr the text
		$x = ceil((($this->size - $tb[2]) / 2) - $rnd);
		//$x = ceil(($this->size - $tb['width']) / 2);

		// Vertically center the text
		$y = ceil(($this->size - $tb[7] - $rnd) / 2);
		//$y = ceil(($this->size - $tb['height']) / 2);
		//$y = $this->size - $y;

		// Print Text On Image
		imagettftext($image, $fontsize, 0, $x, $y, $white, $this->getFontPath(), $string);

		imagepng($image);
	}
197877
public function font(String $str, String $size = NULL, String $color = NULL, String $face = NULL, Array $attributes = []) : String
    {
        if( ! empty($size) )
        {
            $attributes['size'] = $size;
        }

        if( ! empty($color) )
        {
            $attributes['color'] = $color;
        }

        if( ! empty($face) )
        {
            $attributes['face'] = $face;
        }

        return $this->_multiElement('font', $str, $attributes);
    }
418596
public function getImgBinary($string, $size = '', $color = '', $bg = '')
    {
        ob_start();
        imagepng($this->getImgResource($string, $size, $color, $bg));

        return ob_get_clean();
    }
743556
public function thumbnail($size = null, $attr = null)
    {
        return get_the_post_thumbnail($this->id(), $size, $attr);
    }
329480
protected void recreateUserLedImages(final int SIZE) {
        if (userLedImageOff != null) {
            userLedImageOff.flush();
        }
        userLedImageOff = create_LED_Image(SIZE, 0, model.getUserLedColor());

        if (userLedImageOn != null) {
            userLedImageOn.flush();
        }
        userLedImageOn = create_LED_Image(SIZE, 1, model.getUserLedColor());
    }
1294825
public function displayImage($string, $size = 64, $color = null, $backgroundColor = null)
    {
        header('Content-Type: '.$this->generator->getMimeType());
        echo $this->getImageData($string, $size, $color, $backgroundColor);
    }
574206
public function getImageData($string, $size = 64, $color = null)
	{
		ob_start();
		$this->generateImage($string, $size, $color);
		$imageData = ob_get_contents();
		ob_end_clean();

		return $imageData;
	}
1320911
public function save($string, $size, $color, $bg, $target)
    {
        return (!file_exists($target)) ? file_put_contents("$target", $this->getImgData($string, $size, $color, $bg)) : false;
    }
400413
public function generateImageUrl($file, $size=null)
	{
		$url = $this->config->get('prefix').'/'.$file;

		if (!is_null($size)) {
			$url .= '?size='.$size;
		}

		return URL::to($url);
	}
1344473
protected function render( $text, $url, $color = 'blue' ) {
		if ( ! in_array( $color, [ 'blue', 'green', 'red' ], true ) ) {
			$color = 'blue';
		}

		return $this->engine->render(
			'emails/components/button.php',
			compact( 'text', 'url', 'color' )
		);
	}
938397
protected function yell($text, $length = 40, $color = 'green') {
    $format = "<fg=white;bg=$color;options=bold>%s</fg=white;bg=$color;options=bold>";
    $this->formattedOutput($text, $length, $format);
  }
532085
static public function writeOutput($text, $color = '')
    {
        switch ($color) {
            case self::COLOR_WHITE:
                $out = "[0m";
                break;
            case self::COLOR_WHITE_BOLD:
                $out = "[1m";
                break;
            case self::COLOR_WHITE_DIM:
                $out = "[2m";
                break;
            case self::COLOR_RED:
                $out = "[0;31m";
                break;
            case self::COLOR_RED_BOLD:
                $out = "[1;31m";
                break;
            case self::COLOR_RED_DIM:
                $out = "[2;31m";
                break;
            case self::COLOR_GREEN:
                $out = "[0;32m";
                break;
            case self::COLOR_GREEN_BOLD:
                $out = "[1;32m";
                break;
            case self::COLOR_GREEN_DIM:
                $out = "[2;32m";
                break;
            case self::COLOR_YELLOW:
                $out = "[0;33m";
                break;
            case self::COLOR_YELLOW_BOLD:
                $out = "[1;33m";
                break;
            case self::COLOR_YELLOW_DIM:
                $out = "[2;33m";
                break;
            default:
                echo UString::newLine() . $text;

                return true;
        }

        echo UString::newLine() . chr(27) . $out . $text . chr(27) . "[0m";

        return true;
    }
795021
private function text($text, $size, $x, $y, $color = 'black', $font = 'swiss_normal', $angle = 0)
    {
        imagettftext($this->image, $size, $angle, $x, $y, $this->colors[$color], $this->fonts[$font], $text);
    }
1205487
public static function fromRgbaString(string $string) : TransparentColour
    {
        list($r, $g, $b, $a) = ColourStringParser::parseRgbaString($string);

        return new self(new Colour($r, $g, $b), $a);
    }
666642
protected function processImage($column, $file, $filename, $name = null, $size = false)
  {
    if (!is_file($file)) {
      Exception::ThrowError(Exception::FILE_NOT_EXISTS, $file);
    }

    $ext  = strtolower(pathinfo($file, PATHINFO_EXTENSION));
    $path = $this->getFilesPath() . $filename;

    /** @var Image $img */
    $method = 'prepareImageFor' . StaticStringy::upperCamelize($column);
    $img    = call_user_func_array(array($this, $method), array($file, $size));
    if ($img instanceof Image) {
      $img->save($path);
      $w = $img->getWidth();
      $h = $img->getHeight();
    } else {
      $this->copyFile($file, $path);
      list($w, $h) = getimagesize($path);
    }

    $file_arr = array(
      'file'      => $filename,
      'extension' => $ext,
      'size'      => filesize($path),
      'name'      => $name,
      'width'     => $w,
      'height'    => $h,
    );

    if ($size) {
      $this->resetSerializedCache($column);
      $arr = $this->getSerialized($column);

      $arr[$size] = $file_arr;
    } else {
      $arr = $file_arr;
    }

    return $this->setSerialized($column, $arr);
  }
674196
public static function output($message, $color = null)
    {
        if (is_string($color)) {
            $message = sprintf($color, $message);
        }

        if (is_null(self::$map)) {
            self::setMap();
        }

        call_user_func(self::$map, $message);
    }
84479
public function pad($width, $height, $color = array(255, 255, 255))
    {
        // no resize - woohoo!
        if ($width == $this->currentDimensions['width'] && $height == $this->currentDimensions['height']) {
            return $this;
        }

        // create the working image
        if (function_exists('imagecreatetruecolor')) {
            $this->workingImage = imagecreatetruecolor($width, $height);
        } else {
            $this->workingImage = imagecreate($width, $height);
        }

        // create the fill color
        $fillColor = imagecolorallocate($this->workingImage, $color[0], $color[1], $color[2]);

        // fill our working image with the fill color
        imagefill($this->workingImage, 0, 0, $fillColor);

        // copy the image into the center of our working image
        imagecopyresampled($this->workingImage, $this->oldImage, intval(($width - $this->currentDimensions['width']) / 2), intval(($height - $this->currentDimensions['height']) / 2), 0, 0, $this->currentDimensions['width'], $this->currentDimensions['height'], $this->currentDimensions['width'], $this->currentDimensions['height']);

        // update all the variables and resources to be correct
        $this->oldImage = $this->workingImage;
        $this->currentDimensions['width'] = $width;
        $this->currentDimensions['height'] = $height;

        return $this;
    }