/** * @param resource $resource * @param int $width * @param int $height */ private function __construct($resource, $width, $height) { $this->resource = $resource; $this->width = $width; $this->height = $height; $this->lastCoords = new Coords(0, 0); $this->backgroundColor = Color::createWhite(); }
/** * @param $color * @return $this */ public function colorify($color) { $this->checkFinalized(); $color = Color::parse($color); $this->red($color->getRed()); $this->green($color->getGreen()); $this->blue($color->getBlue()); $this->alpha($color->getAlpha()); return $this; }
/** * @param $color * @return $this * @throws \Exception */ public function fill($color) { $this->checkFinalized(); $command = new Command(__TRAIT__, function (Command $command) { return ' -fill "' . $command->color->getHEXAString() . '"'; }); $command->color = Color::parse($color); $this->addCommand($command); return $this; }
/** * @param string $background * @return $this */ public function background($background = 'none') { $this->checkFinalized(); $command = new Command(__TRAIT__, function (Command $command) { return ' -background ' . ($command->background->isNone() ? 'none' : '"' . $command->background->getHEXAString() . '"'); }); $command->background = Color::parse($background); $this->addCommand($command); return $this; }
/** * @param $width * @param $height * @param string $background * @return $this * @throws \Exception */ public function create($width, $height, $background = 'none') { $this->checkFinalized(); $command = new Command(__TRAIT__, function (Command $command) { return ' -size ' . $command->width . 'x' . $command->height . ' xc:' . ($command->background->isNone() ? 'none' : '"' . $command->background->getHEXAString() . '"'); }); $command->width = $width; $command->height = $height; $command->background = Color::parse($background); $this->addCommand($command); return $this; }