Draws a Bar of $color depending of the resolution.

@param resource $img
@param int $color
336790
protected function drawSingleBar($im, $color) {
        $this->drawFilledRectangle($im, $this->positionX, 0, $this->positionX, $this->thickness - 1, $color);
    }
781081
public function draw($im) {
        // Checksum
        $this->calculateChecksum();
        $temp_text = $this->text . $this->keys[$this->checksumValue];

        // Starting Code
        $this->drawChar($im, '000', true);

        // Draw First 4 Chars (Left-Hand)
        for ($i = 0; $i < 4; $i++) {
            $this->drawChar($im, $this->findCode($temp_text[$i]), false);
        }

        // Draw Center Guard Bar
        $this->drawChar($im, '00000', false);

        // Draw Last 4 Chars (Right-Hand)
        for ($i = 4; $i < 8; $i++) {
            $this->drawChar($im, $this->findCode($temp_text[$i]), true);
        }

        // Draw Right Guard Bar
        $this->drawChar($im, '000', true);
        $this->drawText($im, 0, 0, $this->positionX, $this->thickness);

        if ($this->isDefaultEanLabelEnabled()) {
            $dimension = $this->labelRight->getDimension();
            $this->drawExtendedBars($im, $dimension[1] - 2);
        }
    }
977944
public function setBackgroundColor(int $color) : void
    {
        $background = $this->info(true)->backgroundImage;

        $this->set([
            'backgroundImage' => [
                'color' => sprintf('%06X', $color),
                'sourceUrl' => $background->sourceUrl ?? ''
            ]
        ]);
    }
1352148
private function createEllipse($color)
    {
        $alpha = imagecolorallocatealpha($this->resource, 255, 255, 255, 127);
        imagefill($this->resource, 0, 0, $alpha);

        imagefilledellipse(
            $this->resource,
            $this->width / 2,
            $this->height / 2,
            $this->width,
            $this->height,
            $color
        );
    }
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);
	}
479769
static function createImage( $width, $height, &$useTruecolor )
    {
        if ( $useTruecolor === null )
        {
//             print( "has GD2='" . eZImageInterface::hasGD2() . "'<br/>" );
            $useTruecolor = eZImageInterface::hasGD2();
        }
        if ( $useTruecolor and
             !function_exists( 'ImageCreateTrueColor' ) )
        {
            eZDebug::writeWarning( 'Function ImageCreateTrueColor does not exist, cannot create true color images', __METHOD__ );
            $useTruecolor = false;
        }
        if ( $useTruecolor )
            $imageObject = ImageCreateTrueColor( $width, $height );
        else
            $imageObject = ImageCreate( $width, $height );
        return $imageObject;
    }
254136
public void drawImage(Image image, float x, float y, Color col) {
		predraw();
		image.draw(x, y, col);
		currentColor.bind();
		postdraw();
	}
1087567
private static function colorBlend($imagickInstance, $color, $alpha = 1, $composite_flag = \Imagick::COMPOSITE_COLORIZE)
    {
        $draw = new \ImagickDraw();
        $draw->setFillColor($color);

        $width = $imagickInstance->getImageWidth();
        $height = $imagickInstance->getImageHeight();

        $draw->rectangle(0, 0, $width, $height);

        $temporary = new \Imagick();
        $temporary->setBackgroundColor(new \ImagickPixel('transparent'));
        $temporary->newImage($width, $height, new \ImagickPixel('transparent'));
        $temporary->setImageFormat('png32');
        $temporary->drawImage($draw);

        if (method_exists($imagickInstance, 'setImageClipMask')) { // ImageMagick < 7
            $alphaChannel = clone $imagickInstance;
            $alphaChannel->setImageAlphaChannel(\Imagick::ALPHACHANNEL_EXTRACT);
            $alphaChannel->negateImage(false, \Imagick::CHANNEL_ALL);
            $imagickInstance->setImageClipMask($alphaChannel);
        } else {
            // need to figure out how to add support for maintaining opacity in ImageMagick 7
        }

        $clone = clone $imagickInstance;
        $clone->compositeImage($temporary, $composite_flag, 0, 0);

        if (method_exists($clone, 'setImageAlpha')) { // ImageMagick >= 7
            $clone->setImageAlpha($alpha);
        } else {
            $clone->setImageOpacity($alpha);
        }
        
        $imagickInstance->compositeImage($clone, \Imagick::COMPOSITE_DEFAULT, 0, 0);
    }
799434
public static function rgba(Color $color, $alpha = 1.0)
    {
        return sprintf(
            'rgba(%d, %d, %d, %s)',
            $color->getRgb()['r'],
            $color->getRgb()['g'],
            $color->getRgb()['b'],
            $alpha + 0
        );
    }
276317
public function setLineColor($r, $g, $b)
    {

        $this->ink['line'] = imagecolorallocate($this->im, $r, $g, $b);
    }
1184194
private function getColorID($color)
    {
        list ($r, $g, $b) = explode(
            ' ',
            implode(' ', str_split(strtoupper(3 === strlen($color) ? $color . $color : $color), 2))
        );

        return imagecolorallocate($this->resource, hexdec($r), hexdec($g), hexdec($b));
    }
47800
function setFgColor($color)
    {
        $value = $this->_getColor($color);
        $this->_fg_color = $value;
        if ($this->_pattern == 0) { // force color to be seen
            $this->_pattern = 1;
        }
    }
158031
public function write($x, $y, $color)
    {
        if(isset($this->canvas[$y][$x])) {
            $this->canvas[$y][$x] = $color;
        }
    }
547093
public function beginShape(\Jdenticon\Color $color)
    {
        $this->draw->setFillColor($color->__toString());
        $this->draw->pathStart();
    }
1155768
public function setBackgroundColor(\Jdenticon\Color $color)
    {
        parent::setBackgroundColor($color);
        $this->canvas->backColor = $this->backgroundColor->toRgba();
    }
771133
public static function load($color, $resource)
    {
        if ($color === 'transparent') {

            return imagecolorallocatealpha($resource, 0, 0, 0, 127);
        }

        $gdpixel = new GDPixel($color);

        return imagecolorallocate($resource, $gdpixel->channelR, $gdpixel->channelG, $gdpixel->channelB);
    }
1359929
public function png(&$img)
    {
        if (is_null($this->center) || is_null($this->radius)) {
            throw new \RuntimeException('Before exporting to PNG, you must give center and radius!');
        }

        imagefilledellipse(
            $img,
            $this->center->x,
            $this->center->y,
            $this->radius->w,
            $this->radius->h,
            $this->color->gd($img)
        );
    }