1<?php
2
3/*
4 * This file is part of the Imagine package.
5 *
6 * (c) Bulat Shakirzyanov <mallluhuct@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Imagine\Filter\Basic;
13
14use Imagine\Image\ImageInterface;
15use Imagine\Image\BoxInterface;
16use Imagine\Image\PointInterface;
17use Imagine\Filter\FilterInterface;
18
19/**
20 * A crop filter
21 */
22class Crop implements FilterInterface
23{
24    /**
25     * @var PointInterface
26     */
27    private $start;
28
29    /**
30     * @var BoxInterface
31     */
32    private $size;
33
34    /**
35     * Constructs a Crop filter with given x, y, coordinates and crop width and
36     * height values
37     *
38     * @param PointInterface $start
39     * @param BoxInterface   $size
40     */
41    public function __construct(PointInterface $start, BoxInterface $size)
42    {
43        $this->start = $start;
44        $this->size  = $size;
45    }
46
47    /**
48     * {@inheritdoc}
49     */
50    public function apply(ImageInterface $image)
51    {
52        return $image->crop($this->start, $this->size);
53    }
54}
55