Get Image core.
public getCore ( ) : resource | Imagick | ||
Результат | resource | Imagick | GD resource or Imagick instance |
/** * @param ImageInterface $image * @return Image */ public function draw($image) { // Localize vars $width = $image->getWidth(); $height = $image->getHeight(); $imagick = $image->getCore(); $draw = new \ImagickDraw(); $strokeColor = new \ImagickPixel($this->getColor()->getHexString()); $fillColor = new \ImagickPixel('rgba(0,0,0,0)'); $draw->setStrokeOpacity(1); $draw->setStrokeColor($strokeColor); $draw->setFillColor($fillColor); list($x1, $y1) = $this->point1; list($x2, $y2) = $this->control; list($x3, $y3) = $this->point2; $draw->pathStart(); $draw->pathMoveToAbsolute($x1, $y1); $draw->pathCurveToQuadraticBezierAbsolute($x2, $y2, $x3, $y3); $draw->pathFinish(); // Render the draw commands in the ImagickDraw object $imagick->drawImage($draw); $type = $image->getType(); $file = $image->getImageFile(); return new Image($imagick, $file, $width, $height, $type); // Create new image with updated core }
/** * TODO: Anti-aliased curves * @param ImageInterface $image * @return ImageInterface */ public function draw($image) { list($x, $y) = $this->pos; $left = $x + $this->width / 2; $top = $y + $this->height / 2; if (null !== $this->fillColor) { list($r, $g, $b, $alpha) = $this->fillColor->getRgba(); $fillColorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, Editor::gdAlpha($alpha)); imagefilledellipse($image->getCore(), $left, $top, $this->width, $this->height, $fillColorResource); } // Create borders. It will be placed on top of the filled ellipse (if present) if (0 < $this->getBorderSize() and null !== $this->borderColor) { // With border > 0 AND borderColor !== null list($r, $g, $b, $alpha) = $this->borderColor->getRgba(); $borderColorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, Editor::gdAlpha($alpha)); imageellipse($image->getCore(), $left, $top, $this->width, $this->height, $borderColorResource); } return $image; }
/** * @link http://members.chello.at/easyfilter/bresenham.pdf * @param ImageInterface $image * @return Image */ public function draw($image) { // Localize vars $width = $image->getWidth(); $height = $image->getHeight(); $gd = $image->getCore(); list($x0, $y0) = $this->point1; list($x1, $y1) = $this->control; list($x2, $y2) = $this->point2; $this->plot($gd, $x0, $y0, $x1, $y1, $x2, $y2); $type = $image->getType(); $file = $image->getImageFile(); return new Image($gd, $file, $width, $height, $type); // Create new image with updated core }
/** * @param ImageInterface $image * @return ImageInterface */ public function draw($image) { $strokeColor = new \ImagickPixel($this->getBorderColor()->getHexString()); $fillColor = new \ImagickPixel($this->getFillColor()->getHexString()); $draw = new \ImagickDraw(); $draw->setStrokeColor($strokeColor); $draw->setFillColor($fillColor); $draw->setStrokeWidth($this->borderSize); list($x, $y) = $this->pos; $left = $x + $this->width / 2; $top = $y + $this->height / 2; $draw->ellipse($left, $top, $this->width / 2, $this->height / 2, 0, 360); $image->getCore()->drawImage($draw); return $image; }
/** * @param ImageInterface $image * @return Image */ public function draw($image) { // Localize vars $width = $image->getWidth(); $height = $image->getHeight(); $imagick = $image->getCore(); $draw = new \ImagickDraw(); $strokeColor = new \ImagickPixel($this->getColor()->getHexString()); $fillColor = new \ImagickPixel('rgba(0,0,0,0)'); $draw->setStrokeOpacity(1); $draw->setStrokeColor($strokeColor); $draw->setFillColor($fillColor); $points = array(array('x' => $this->point1[0], 'y' => $this->point1[1]), array('x' => $this->control1[0], 'y' => $this->control1[1]), array('x' => $this->control2[0], 'y' => $this->control2[1]), array('x' => $this->point2[0], 'y' => $this->point2[1])); $draw->bezier($points); // Render the draw commands in the ImagickDraw object $imagick->drawImage($draw); $type = $image->getType(); $file = $image->getImageFile(); return new Image($imagick, $file, $width, $height, $type); // Create new image with updated core }