/** * {@inheritdoc} * * @return ImageInterface */ public function fill(FillInterface $fill) { try { $draw = new \GmagickDraw(); $size = $this->getSize(); $w = $size->getWidth(); $h = $size->getHeight(); for ($x = 0; $x <= $w; $x++) { for ($y = 0; $y <= $h; $y++) { $pixel = $this->getColor($fill->getColor(new Point($x, $y))); $draw->setfillcolor($pixel); $draw->point($x, $y); $pixel = null; } } $this->gmagick->drawimage($draw); $draw = null; } catch (\GmagickException $e) { throw new RuntimeException('Fill operation failed', $e->getCode(), $e); } return $this; }
/** * {@inheritdoc} * * @return ImageInterface */ public function fill(FillInterface $fill) { $size = $this->getSize(); for ($x = 0, $width = $size->getWidth(); $x < $width; $x++) { for ($y = 0, $height = $size->getHeight(); $y < $height; $y++) { if (false === imagesetpixel($this->resource, $x, $y, $this->getColor($fill->getColor(new Point($x, $y))))) { throw new RuntimeException('Fill operation failed'); } } } return $this; }
/** * Checks whether given $fill is linear and opaque * * @param FillInterface $fill * * @return Boolean */ private function isLinearOpaque(FillInterface $fill) { return $fill instanceof Linear && $fill->getStart()->isOpaque() && $fill->getEnd()->isOpaque(); }