/** * Draws an ellipse on the handle * * @param ImageMagick-object $handle The handle on which the ellipse is drawn * @param Zend_Image_Action_DrawEllipse $ellipseObject The object that with all info */ public function perform(Zend_Image_Adapter_ImageMagick $adapter, Zend_Image_Action_DrawEllipse $ellipseObject) { $draw = new ImagickDraw(); $strokeColor = (string) $ellipseObject->getStrokeColor(); $strokeAlpha = $ellipseObject->getStrokeAlpha() * 0.01; $draw->setStrokeColor($strokeColor); $draw->setStrokeOpacity($strokeAlpha); $draw->setStrokeWidth($ellipseObject->getStrokeWidth()); $strokeDashArray = $ellipseObject->getStrokeDashPattern(); if (count($strokeDashArray) > 0) { $draw->setStrokeDashArray($strokeDashArray); } $draw->setStrokeDashOffset($ellipseObject->getStrokeDashOffset()); if ($ellipseObject->filled()) { $fillColor = (string) $ellipseObject->getFillColor(); $draw->setFillColor($fillColor); $draw->setFillOpacity($ellipseObject->getFillAlpha() * 0.01); } else { $draw->setFillOpacity(0); } $width = $ellipseObject->getWidth(); $height = $ellipseObject->getHeight(); $x = $ellipseObject->getLocation()->getX(); $y = $ellipseObject->getLocation()->getY(); $draw->ellipse($x, $y, $width / 2, $height / 2, 0, 360); $adapter->getHandle()->drawImage($draw); }
/** * Draws an ellipse on the handle * * @param GD-object $handle The handle on which the ellipse is drawn * @param Zend_Image_Action_DrawEllipse $ellipseObject The object that with all info */ public function perform($handle, Zend_Image_Action_DrawEllipse $ellipseObject) { // As of ZF2.0 / PHP5.3, this can be made static. if($ellipseObject->filled()){ $color = $ellipseObject->getFillColor()->getRgb(); $alpha = $ellipseObject->getFillAlpha(); }else{ $color = $ellipseObject->getStrokeColor()->getRgb(); $alpha = $ellipseObject->getStrokeAlpha(); } $colorAlphaAlloc = imagecolorallocatealpha($handle->getHandle(), $color['red'], $color['green'], $color['blue'], 127 - $alpha * 1.27); if($ellipseObject->filled()) { imagefilledellipse($handle->getHandle(), $ellipseObject->getLocation()->getX(), $ellipseObject->getLocation()->getY(), $ellipseObject->getWidth(), $ellipseObject->getHeight(), $colorAlphaAlloc); } else { imageellipse($handle->getHandle(), $ellipseObject->getLocation()->getX(), $ellipseObject->getLocation()->getY(), $ellipseObject->getWidth(), $ellipseObject->getHeight(), $colorAlphaAlloc); } }