Файл: concrete5.7.5.6/concrete/vendor/imagine/imagine/lib/Imagine/Image/Point/Center.php
Строк: 67
<?php
/*
* This file is part of the Imagine package.
*
* (c) Bulat Shakirzyanov <mallluhuct@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ImagineImagePoint;
use ImagineImageBoxInterface;
use ImagineImagePoint as OriginalPoint;
use ImagineImagePointInterface;
/**
* Point center
*/
final class Center implements PointInterface
{
/**
* @var BoxInterface
*/
private $box;
/**
* Constructs coordinate with size instance, it needs to be relative to
*
* @param BoxInterface $box
*/
public function __construct(BoxInterface $box)
{
$this->box = $box;
}
/**
* {@inheritdoc}
*/
public function getX()
{
return ceil($this->box->getWidth() / 2);
}
/**
* {@inheritdoc}
*/
public function getY()
{
return ceil($this->box->getHeight() / 2);
}
/**
* {@inheritdoc}
*/
public function in(BoxInterface $box)
{
return $this->getX() < $box->getWidth() && $this->getY() < $box->getHeight();
}
/**
* {@inheritdoc}
*/
public function move($amount)
{
return new OriginalPoint($this->getX() + $amount, $this->getY() + $amount);
}
/**
* {@inheritdoc}
*/
public function __toString()
{
return sprintf('(%d, %d)', $this->getX(), $this->getY());
}
}