mirror of
https://github.com/Intervention/image.git
synced 2025-08-22 05:22:50 +02:00
Add doc blocks
This commit is contained in:
@@ -16,11 +16,21 @@ class Frame implements FrameInterface
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::toImage()
|
||||
*/
|
||||
public function toImage(DriverInterface $driver): ImageInterface
|
||||
{
|
||||
return new Image($driver, new Core($this->native()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::setNative()
|
||||
*/
|
||||
public function setNative($native): FrameInterface
|
||||
{
|
||||
$this->native = $native;
|
||||
@@ -28,11 +38,21 @@ class Frame implements FrameInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::native()
|
||||
*/
|
||||
public function native(): Imagick
|
||||
{
|
||||
return $this->native;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::size()
|
||||
*/
|
||||
public function size(): SizeInterface
|
||||
{
|
||||
return new Rectangle(
|
||||
@@ -41,11 +61,21 @@ class Frame implements FrameInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::delay()
|
||||
*/
|
||||
public function delay(): float
|
||||
{
|
||||
return $this->native->getImageDelay() / 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::setDelay()
|
||||
*/
|
||||
public function setDelay(float $delay): FrameInterface
|
||||
{
|
||||
$this->native->setImageDelay(intval(round($delay * 100)));
|
||||
@@ -53,11 +83,21 @@ class Frame implements FrameInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::dispose()
|
||||
*/
|
||||
public function dispose(): int
|
||||
{
|
||||
return $this->native->getImageDispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::setDispose()
|
||||
*/
|
||||
public function setDispose(int $dispose): FrameInterface
|
||||
{
|
||||
$this->native->setImageDispose($dispose);
|
||||
@@ -65,6 +105,11 @@ class Frame implements FrameInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::setOffset()
|
||||
*/
|
||||
public function setOffset(int $left, int $top): FrameInterface
|
||||
{
|
||||
$this->native->setImagePage(
|
||||
@@ -77,21 +122,41 @@ class Frame implements FrameInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::offsetLeft()
|
||||
*/
|
||||
public function offsetLeft(): int
|
||||
{
|
||||
return $this->native->getImagePage()['x'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::setOffsetLeft()
|
||||
*/
|
||||
public function setOffsetLeft(int $offset): FrameInterface
|
||||
{
|
||||
return $this->setOffset($offset, $this->offsetTop());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::offsetTop()
|
||||
*/
|
||||
public function offsetTop(): int
|
||||
{
|
||||
return $this->native->getImagePage()['y'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::setOffsetTop()
|
||||
*/
|
||||
public function setOffsetTop(int $offset): FrameInterface
|
||||
{
|
||||
return $this->setOffset($this->offsetLeft(), $offset);
|
||||
|
@@ -20,13 +20,6 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
|
||||
$this->addPoint(new Point($this->pivot->x(), $this->pivot->y() - $height));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rectangle dimensions to given width & height
|
||||
*
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @return Rectangle
|
||||
*/
|
||||
public function setSize(int $width, int $height): self
|
||||
{
|
||||
return $this->setWidth($width)->setHeight($height);
|
||||
@@ -60,15 +53,6 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move current pivot of current rectangle to given position
|
||||
* and moves point automatically by offset.
|
||||
*
|
||||
* @param string $position
|
||||
* @param int $offset_x
|
||||
* @param int $offset_y
|
||||
* @return Rectangle
|
||||
*/
|
||||
public function movePivot(string $position, int $offset_x = 0, int $offset_y = 0): self
|
||||
{
|
||||
switch (strtolower($position)) {
|
||||
@@ -159,13 +143,6 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the relative position to another Size
|
||||
* based on the pivot point settings of both sizes.
|
||||
*
|
||||
* @param SizeInterface $rectangle
|
||||
* @return PointInterface
|
||||
*/
|
||||
public function relativePositionTo(SizeInterface $rectangle): PointInterface
|
||||
{
|
||||
return new Point(
|
||||
@@ -192,21 +169,11 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if size is landscape format
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isLandscape(): bool
|
||||
{
|
||||
return $this->width() > $this->height();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if size is portrait format
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isPortrait(): bool
|
||||
{
|
||||
return $this->width() < $this->height();
|
||||
|
@@ -4,17 +4,101 @@ namespace Intervention\Image\Interfaces;
|
||||
|
||||
interface FrameInterface
|
||||
{
|
||||
public function native();
|
||||
/**
|
||||
* Return image data of frame in driver specific format
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function native(): mixed;
|
||||
|
||||
/**
|
||||
* Set image data of drame in driver specific format
|
||||
*
|
||||
* @param mixed $native
|
||||
* @return FrameInterface
|
||||
*/
|
||||
public function setNative($native): FrameInterface;
|
||||
|
||||
/**
|
||||
* Transform frame into an image
|
||||
*
|
||||
* @param DriverInterface $driver
|
||||
* @return ImageInterface
|
||||
*/
|
||||
public function toImage(DriverInterface $driver): ImageInterface;
|
||||
|
||||
/**
|
||||
* Get image size of current frame
|
||||
*
|
||||
* @return SizeInterface
|
||||
*/
|
||||
public function size(): SizeInterface;
|
||||
|
||||
/**
|
||||
* Return animation delay of current frame in seconds
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function delay(): float;
|
||||
|
||||
/**
|
||||
* Set animation frame delay in seoncds
|
||||
*
|
||||
* @param float $delay
|
||||
* @return FrameInterface
|
||||
*/
|
||||
public function setDelay(float $delay): FrameInterface;
|
||||
|
||||
/**
|
||||
* Get disposal method of current frame
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function dispose(): int;
|
||||
|
||||
/**
|
||||
* Set disposal method of current frame
|
||||
*
|
||||
* @return FrameInterface
|
||||
*/
|
||||
public function setDispose(int $dispose): FrameInterface;
|
||||
|
||||
/**
|
||||
* Set pixel offset of current frame
|
||||
*
|
||||
* @param int $left
|
||||
* @param int $top
|
||||
* @return FrameInterface
|
||||
*/
|
||||
public function setOffset(int $left, int $top): FrameInterface;
|
||||
|
||||
/**
|
||||
* Get left offset in pixels
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function offsetLeft(): int;
|
||||
|
||||
/**
|
||||
* Set left pixel offset for current frame
|
||||
*
|
||||
* @param int $offset
|
||||
* @return FrameInterface
|
||||
*/
|
||||
public function setOffsetLeft(int $offset): FrameInterface;
|
||||
|
||||
/**
|
||||
* Get top pixel offset of current frame
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function offsetTop(): int;
|
||||
|
||||
/**
|
||||
* Set top pixel offset of current frame
|
||||
*
|
||||
* @param int $offset
|
||||
* @return FrameInterface
|
||||
*/
|
||||
public function setOffsetTop(int $offset): FrameInterface;
|
||||
}
|
||||
|
@@ -4,18 +4,98 @@ namespace Intervention\Image\Interfaces;
|
||||
|
||||
interface SizeInterface
|
||||
{
|
||||
/**
|
||||
* Get width
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function width(): int;
|
||||
|
||||
/**
|
||||
* Get height
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function height(): int;
|
||||
|
||||
/**
|
||||
* Get pivot point
|
||||
*
|
||||
* @return PointInterface
|
||||
*/
|
||||
public function pivot(): PointInterface;
|
||||
|
||||
/**
|
||||
* Set width
|
||||
*
|
||||
* @param int $width
|
||||
* @return SizeInterface
|
||||
*/
|
||||
public function setWidth(int $width): SizeInterface;
|
||||
|
||||
/**
|
||||
* Set height
|
||||
*
|
||||
* @param int $height
|
||||
* @return SizeInterface
|
||||
*/
|
||||
public function setHeight(int $height): SizeInterface;
|
||||
|
||||
/**
|
||||
* Set pivot point
|
||||
*
|
||||
* @param PointInterface $pivot
|
||||
* @return SizeInterface
|
||||
*/
|
||||
public function setPivot(PointInterface $pivot): SizeInterface;
|
||||
|
||||
/**
|
||||
* Calculate aspect ratio of the current size
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function aspectRatio(): float;
|
||||
|
||||
/**
|
||||
* Determine if current size fits into given size
|
||||
*
|
||||
* @param SizeInterface $size
|
||||
* @return bool
|
||||
*/
|
||||
public function fitsInto(SizeInterface $size): bool;
|
||||
|
||||
/**
|
||||
* Determine if size is in landscape format
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isLandscape(): bool;
|
||||
|
||||
/**
|
||||
* Determine if size is in portrait format
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isPortrait(): bool;
|
||||
|
||||
/**
|
||||
* Move pivot to given position in size
|
||||
*
|
||||
* @param string $position
|
||||
* @param int $offset_x
|
||||
* @param int $offset_y
|
||||
* @return SizeInterface
|
||||
*/
|
||||
public function movePivot(string $position, int $offset_x = 0, int $offset_y = 0): SizeInterface;
|
||||
public function alignPivotTo(SizeInterface $size, string $position): SizeInterface;
|
||||
|
||||
/**
|
||||
* Calculate the relative position to another Size
|
||||
* based on the pivot point settings of both sizes.
|
||||
*
|
||||
* @param SizeInterface $size
|
||||
* @return PointInterface
|
||||
*/
|
||||
public function relativePositionTo(SizeInterface $size): PointInterface;
|
||||
public function resize(?int $width = null, ?int $height = null): SizeInterface;
|
||||
public function resizeDown(?int $width = null, ?int $height = null): SizeInterface;
|
||||
|
Reference in New Issue
Block a user