$point1
$point1 : array
Starting point. Array of X Y values.
Class CubicBezier
$color : \Grafika\Color
Color of curve.
__construct(array $point1, array $control1, array $control2, array $point2, \Grafika\Color|string $color = '#000000')
Creates a cubic bezier. Cubic bezier has 2 control points.
array | $point1 | Array of X and Y value for start point. |
array | $control1 | Array of X and Y value for control point 1. |
array | $control2 | Array of X and Y value for control point 2. |
array | $point2 | Array of X and Y value for end point. |
\Grafika\Color|string | $color | Color of the curve. Accepts hex string or a Color object. Defaults to black. |
getColor() : \Grafika\Color
draw(\Grafika\ImageInterface $image) : \Grafika\Imagick\Image
\Grafika\ImageInterface | $image |
<?php
namespace Grafika\Imagick\DrawingObject;
use Grafika\DrawingObject\CubicBezier as Base;
use Grafika\DrawingObjectInterface;
use Grafika\Imagick\Image;
use Grafika\ImageInterface;
/**
* Class CubicBezier
* @package Grafika
*/
class CubicBezier extends Base implements DrawingObjectInterface
{
/**
* @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
}
}