vendor/grafika/src/Grafika/Gd/DrawingObject/Rectangle.php
(完整代码) 1KB<?php
namespace Grafika\Gd\DrawingObject;
use Grafika\DrawingObject\Rectangle as Base;
use Grafika\DrawingObjectInterface;
use Grafika\Gd\Editor;
/**
* Class Rectangle
* @package Grafika
*/
class Rectangle extends Base implements DrawingObjectInterface
{
public function draw($image)
{
$x1 = $this->pos[0];
$x2 = $x1 + $this->getWidth();
$y1 = $this->pos[1];
$y2 = $y1 + $this->getHeight();
if( null !== $this->fillColor ){
list($r, $g, $b, $alpha) = $this->fillColor->getRgba();
$fillColorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, Editor::gdAlpha($alpha));
imagefilledrectangle($image->getCore(), $x1, $y1, $x2, $y2, $fillColorResource);
}
// Create borders. It will be placed on top of the filled rectangle (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));
imagerectangle($image->getCore(), $x1, $y1, $x2, $y2, $borderColorResource);
}
return $image;
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
