function renderImage3() { //dupe of two ? $draw = new \ImagickDraw(); $strokeColor = new \ImagickPixel($this->strokeColor); $fillColor = new \ImagickPixel($this->fillColor); $draw->setStrokeWidth(1); $draw->setStrokeColor($strokeColor); $draw->setFillColor($fillColor); $fillRules = [\Imagick::FILLRULE_NONZERO, \Imagick::FILLRULE_EVENODD]; $points = 11; $size = 150; $draw->translate(175, 160); for ($x = 0; $x < 2; $x++) { //$pointsArray = array(); $draw->setFillRule($fillRules[$x]); $draw->pathStart(); for ($n = 0; $n < $points * 2; $n++) { if ($n >= $points) { $angle = fmod($n * 360 * 4 / $points, 360) * pi() / 180; } else { $angle = fmod($n * 360 * 3 / $points, 360) * pi() / 180; } $positionX = $size * sin($angle); $positionY = $size * cos($angle); if ($n == 0) { $draw->pathMoveToAbsolute($positionX, $positionY); } else { $draw->pathLineToAbsolute($positionX, $positionY); } } $draw->pathClose(); $draw->pathFinish(); $draw->translate(325, 0); } //Create an image object which the draw commands can be rendered into $image = new \Imagick(); //$image->newImage(700, 320, $this->backgroundColor); $image->newImage(700, 320, "#eee"); $image->setImageFormat("png"); //Render the draw commands in the ImagickDraw object //into the image. $image->drawImage($draw); //Send the image to the browser header("Content-Type: image/png"); echo $image->getImageBlob(); }
public function drawBlendedChart($points, $curveLinearBlend) { $this->draw->setFillColor('#B42AAF9F'); $this->draw->translate($this->chartWidth / 2, $this->chartHeight / 2); $this->draw->pathStart(); list($nextPositionX, $nextPositionY) = $this->getInterpolatedPosition(0, 0, $points); $this->draw->pathMoveToAbsolute($nextPositionX, $nextPositionY); for ($p = 0; $p < count($points); $p++) { for ($i = 0; $i < $this->segments; $i++) { $curvedPosition = $this->getInterpolatedPosition($p, $i, $points); $linearPosition = $this->getLinearPosition($p, $i, $points); list($nextPositionX, $nextPositionY) = interpolateArray($curveLinearBlend, $curvedPosition, $linearPosition); $this->draw->pathLineToAbsolute($nextPositionX, $nextPositionY); } } $this->draw->pathClose(); $this->draw->pathFinish(); }
function test_path(&$canvas) { $draw = new ImagickDraw(); $draw->setFillColor('transparent'); $draw->setStrokeColor('blue'); $draw->setStrokeWidth(4); $draw->pathStart(); $draw->pathMoveToAbsolute(300, 10); $draw->pathLineToHorizontalRelative(50); $draw->pathLineToVerticalRelative(50); $draw->pathEllipticArcRelative(40, 30, 30, false, true, 60, 10); $draw->pathLineToAbsolute(444, 22); $draw->pathFinish(); $draw->pathStart(); $draw->pathMoveToAbsolute(480, 30); $draw->pathCurveToAbsolute(520, 40, 560, 10, 600, 20); $draw->pathCurveToQuadraticBezierRelative(30, 10, -60, 80); $draw->pathCurveToQuadraticBezierSmoothRelative(20, -50); $draw->pathClose(); $draw->pathFinish(); $canvas->drawImage($draw); }
function setFillRule($fillColor, $strokeColor, $backgroundColor) { $draw = new \ImagickDraw(); $draw->setStrokeWidth(1); $draw->setStrokeColor($strokeColor); $draw->setFillColor($fillColor); $fillRules = [\Imagick::FILLRULE_NONZERO, \Imagick::FILLRULE_EVENODD]; $points = 11; $size = 150; $draw->translate(175, 160); for ($x = 0; $x < 2; $x++) { $draw->setFillRule($fillRules[$x]); $draw->pathStart(); for ($n = 0; $n < $points * 2; $n++) { if ($n >= $points) { $angle = fmod($n * 360 * 4 / $points, 360) * pi() / 180; } else { $angle = fmod($n * 360 * 3 / $points, 360) * pi() / 180; } $positionX = $size * sin($angle); $positionY = $size * cos($angle); if ($n == 0) { $draw->pathMoveToAbsolute($positionX, $positionY); } else { $draw->pathLineToAbsolute($positionX, $positionY); } } $draw->pathClose(); $draw->pathFinish(); $draw->translate(325, 0); } $image = new \Imagick(); $image->newImage(700, 320, $backgroundColor); $image->setImageFormat("png"); $image->drawImage($draw); header("Content-Type: image/png"); echo $image->getImageBlob(); }