Файл: vendor/intervention/image/src/Geometry/Ellipse.php
Строк: 126
<?php
declare(strict_types=1);
namespace InterventionImageGeometry;
use InterventionImageColorsAbstractColor;
use InterventionImageGeometryFactoriesEllipseFactory;
use InterventionImageGeometryTraitsHasBackgroundColor;
use InterventionImageGeometryTraitsHasBorder;
use InterventionImageInterfacesDrawableFactoryInterface;
use InterventionImageInterfacesDrawableInterface;
use InterventionImageInterfacesPointInterface;
class Ellipse implements DrawableInterface
{
use HasBorder;
use HasBackgroundColor;
/**
* Create new ellipse instance.
*/
public function __construct(
protected int $width,
protected int $height,
protected PointInterface $pivot = new Point(),
) {
//
}
/**
* {@inheritdoc}
*
* @see DrawableInterface::position()
*/
public function position(): PointInterface
{
return $this->pivot;
}
/**
* {@inheritdoc}
*
* @see DrawableInterface::setPosition()
*/
public function setPosition(PointInterface $position): self
{
$this->pivot = $position;
return $this;
}
/**
* Return pivot point of Ellipse.
*/
public function pivot(): PointInterface
{
return $this->pivot;
}
/**
* Set size of Ellipse.
*/
public function setSize(int $width, int $height): self
{
return $this->setWidth($width)->setHeight($height);
}
/**
* Set width of Ellipse.
*/
public function setWidth(int $width): self
{
$this->width = $width;
return $this;
}
/**
* Set height of Ellipse.
*/
public function setHeight(int $height): self
{
$this->height = $height;
return $this;
}
/**
* Get width of Ellipse.
*/
public function width(): int
{
return $this->width;
}
/**
* Get height of Ellipse.
*/
public function height(): int
{
return $this->height;
}
/**
* {@inheritdoc}
*
* @see DrawableInterface::factory()
*/
public function factory(): DrawableFactoryInterface
{
return new EllipseFactory($this);
}
/**
* {@inheritdoc}
*
* @see DrawableInterface::adjust()
*/
public function adjust(callable $adjustments): DrawableInterface
{
$factory = $this->factory();
$adjustments($factory);
return $factory->drawable();
}
/**
* Clone ellipse.
*/
public function __clone(): void
{
$this->pivot = clone $this->pivot;
if ($this->backgroundColor instanceof AbstractColor) {
$this->backgroundColor = clone $this->backgroundColor;
}
if ($this->borderColor instanceof AbstractColor) {
$this->borderColor = clone $this->borderColor;
}
}
}