| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/nice/libraries/CBLib/Imagine/Filter/Advanced/ |
Upload File : |
<?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 Imagine\Filter\Advanced;
use Imagine\Filter\FilterInterface;
use Imagine\Image\ImageInterface;
use Imagine\Image\Palette\Color\ColorInterface;
use Imagine\Image\Point;
/**
* A border filter.
*/
class Border implements FilterInterface
{
/**
* @var \Imagine\Image\Palette\Color\ColorInterface
*/
private $color;
/**
* @var int
*/
private $width;
/**
* @var int
*/
private $height;
/**
* Constructs Border filter with given color, width and height.
*
* @param \Imagine\Image\Palette\Color\ColorInterface $color
* @param int $width Width of the border on the left and right sides of the image
* @param int $height Height of the border on the top and bottom sides of the image
*/
public function __construct(ColorInterface $color, $width = 1, $height = 1)
{
$this->color = $color;
$this->width = $width;
$this->height = $height;
}
/**
* {@inheritdoc}
*
* @see \Imagine\Filter\FilterInterface::apply()
*/
public function apply(ImageInterface $image)
{
$size = $image->getSize();
$width = $size->getWidth();
$height = $size->getHeight();
$draw = $image->draw();
// Draw top and bottom lines
$draw
->line(
new Point(0, 0),
new Point($width - 1, 0),
$this->color,
$this->height
)
->line(
new Point($width - 1, $height - 1),
new Point(0, $height - 1),
$this->color,
$this->height
)
;
// Draw sides
$draw
->line(
new Point(0, 0),
new Point(0, $height - 1),
$this->color,
$this->width
)
->line(
new Point($width - 1, 0),
new Point($width - 1, $height - 1),
$this->color,
$this->width
)
;
return $image;
}
}