<?php
namespace Grafika\Imagick\DrawingObject;
use Grafika\DrawingObject\CubicBezier as Base;
use Grafika\DrawingObjectInterface;
use Grafika\Imagick\Image;
use Grafika\ImageInterface;
class CubicBezier extends Base implements DrawingObjectInterface
{
public function draw($image)
{
$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);
$imagick->drawImage($draw);
$type = $image->getType();
$file = $image->getImageFile();
return new Image($imagick, $file, $width, $height, $type); }
}