Вход Регистрация
Файл: concrete5.7.5.6/concrete/vendor/imagine/imagine/lib/Imagine/Filter/Advanced/Border.php
Строк: 64
<?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 ImagineFilterAdvanced;

use 
ImagineFilterFilterInterface;
use 
ImagineImageImageInterface;
use 
ImagineImagePaletteColorColorInterface;
use 
ImagineImagePoint;

/**
 * A border filter
 */
class Border implements FilterInterface
{
    
/**
     * @var ColorInterface
     */
    
private $color;

    
/**
     * @var integer
     */
    
private $width;

    
/**
     * @var integer
     */
    
private $height;

    
/**
     * Constructs Border filter with given color, width and height
     *
     * @param ColorInterface $color
     * @param integer        $width  Width of the border on the left and right sides of the image
     * @param integer        $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}
     */
    
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(00),
                new 
Point($width 10),
                
$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(00),
                new 
Point(0$height 1),
                
$this->color,
                
$this->width
            
)
            ->
line(
                new 
Point($width 10),
                new 
Point($width 1$height 1),
                
$this->color,
                
$this->width
            
)
        ;

        return 
$image;
    }
}
Онлайн: 1
Реклама