vendor/grafika/src/Grafika/Gd/DrawingObject/Ellipse.php
(完整代码) 1KB<?php
namespace Grafika\Gd\DrawingObject;
use Grafika\DrawingObject\Ellipse as Base;
use Grafika\DrawingObjectInterface;
use Grafika\Gd\Editor;
use Grafika\ImageInterface;
/**
* Class Ellipse
* @package Grafika
*/
class Ellipse extends Base implements DrawingObjectInterface
{
/**
* 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;
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
