vendor and env first commit
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Imagick\Shapes;
|
||||
|
||||
use Intervention\Image\Image;
|
||||
|
||||
class CircleShape extends EllipseShape
|
||||
{
|
||||
/**
|
||||
* Diameter of circle in pixels
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $diameter = 100;
|
||||
|
||||
/**
|
||||
* Create new instance of circle
|
||||
*
|
||||
* @param int $diameter
|
||||
*/
|
||||
public function __construct($diameter = null)
|
||||
{
|
||||
$this->width = is_numeric($diameter) ? intval($diameter) : $this->diameter;
|
||||
$this->height = is_numeric($diameter) ? intval($diameter) : $this->diameter;
|
||||
$this->diameter = is_numeric($diameter) ? intval($diameter) : $this->diameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw current circle on given image
|
||||
*
|
||||
* @param Image $image
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @return boolean
|
||||
*/
|
||||
public function applyToImage(Image $image, $x = 0, $y = 0)
|
||||
{
|
||||
return parent::applyToImage($image, $x, $y);
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Imagick\Shapes;
|
||||
|
||||
use Intervention\Image\AbstractShape;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Imagick\Color;
|
||||
|
||||
class EllipseShape extends AbstractShape
|
||||
{
|
||||
/**
|
||||
* Width of ellipse in pixels
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $width = 100;
|
||||
|
||||
/**
|
||||
* Height of ellipse in pixels
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $height = 100;
|
||||
|
||||
/**
|
||||
* Create new ellipse instance
|
||||
*
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
*/
|
||||
public function __construct($width = null, $height = null)
|
||||
{
|
||||
$this->width = is_numeric($width) ? intval($width) : $this->width;
|
||||
$this->height = is_numeric($height) ? intval($height) : $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw ellipse instance on given image
|
||||
*
|
||||
* @param Image $image
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @return boolean
|
||||
*/
|
||||
public function applyToImage(Image $image, $x = 0, $y = 0)
|
||||
{
|
||||
$circle = new \ImagickDraw;
|
||||
|
||||
// set background
|
||||
$bgcolor = new Color($this->background);
|
||||
$circle->setFillColor($bgcolor->getPixel());
|
||||
|
||||
// set border
|
||||
if ($this->hasBorder()) {
|
||||
$border_color = new Color($this->border_color);
|
||||
$circle->setStrokeWidth($this->border_width);
|
||||
$circle->setStrokeColor($border_color->getPixel());
|
||||
}
|
||||
|
||||
$circle->ellipse($x, $y, $this->width / 2, $this->height / 2, 0, 360);
|
||||
|
||||
$image->getCore()->drawImage($circle);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Imagick\Shapes;
|
||||
|
||||
use Intervention\Image\AbstractShape;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Imagick\Color;
|
||||
|
||||
class LineShape extends AbstractShape
|
||||
{
|
||||
/**
|
||||
* Starting point x-coordinate of line
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $x = 0;
|
||||
|
||||
/**
|
||||
* Starting point y-coordinate of line
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $y = 0;
|
||||
|
||||
/**
|
||||
* Color of line
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $color = '#000000';
|
||||
|
||||
/**
|
||||
* Width of line in pixels
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $width = 1;
|
||||
|
||||
/**
|
||||
* Create new line shape instance
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
*/
|
||||
public function __construct($x = null, $y = null)
|
||||
{
|
||||
$this->x = is_numeric($x) ? intval($x) : $this->x;
|
||||
$this->y = is_numeric($y) ? intval($y) : $this->y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current line color
|
||||
*
|
||||
* @param string $color
|
||||
* @return void
|
||||
*/
|
||||
public function color($color)
|
||||
{
|
||||
$this->color = $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current line width in pixels
|
||||
*
|
||||
* @param int $width
|
||||
* @return void
|
||||
*/
|
||||
public function width($width)
|
||||
{
|
||||
$this->width = $width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw current instance of line to given endpoint on given image
|
||||
*
|
||||
* @param Image $image
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @return boolean
|
||||
*/
|
||||
public function applyToImage(Image $image, $x = 0, $y = 0)
|
||||
{
|
||||
$line = new \ImagickDraw;
|
||||
|
||||
$color = new Color($this->color);
|
||||
$line->setStrokeColor($color->getPixel());
|
||||
$line->setStrokeWidth($this->width);
|
||||
|
||||
$line->line($this->x, $this->y, $x, $y);
|
||||
$image->getCore()->drawImage($line);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Imagick\Shapes;
|
||||
|
||||
use Intervention\Image\AbstractShape;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Imagick\Color;
|
||||
|
||||
class PolygonShape extends AbstractShape
|
||||
{
|
||||
/**
|
||||
* Array of points of polygon
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $points;
|
||||
|
||||
/**
|
||||
* Create new polygon instance
|
||||
*
|
||||
* @param array $points
|
||||
*/
|
||||
public function __construct($points)
|
||||
{
|
||||
$this->points = $this->formatPoints($points);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw polygon on given image
|
||||
*
|
||||
* @param Image $image
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @return boolean
|
||||
*/
|
||||
public function applyToImage(Image $image, $x = 0, $y = 0)
|
||||
{
|
||||
$polygon = new \ImagickDraw;
|
||||
|
||||
// set background
|
||||
$bgcolor = new Color($this->background);
|
||||
$polygon->setFillColor($bgcolor->getPixel());
|
||||
|
||||
// set border
|
||||
if ($this->hasBorder()) {
|
||||
$border_color = new Color($this->border_color);
|
||||
$polygon->setStrokeWidth($this->border_width);
|
||||
$polygon->setStrokeColor($border_color->getPixel());
|
||||
}
|
||||
|
||||
$polygon->polygon($this->points);
|
||||
|
||||
$image->getCore()->drawImage($polygon);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format polygon points to Imagick format
|
||||
*
|
||||
* @param Array $points
|
||||
* @return Array
|
||||
*/
|
||||
private function formatPoints($points)
|
||||
{
|
||||
$ipoints = [];
|
||||
$count = 1;
|
||||
|
||||
foreach ($points as $key => $value) {
|
||||
if ($count%2 === 0) {
|
||||
$y = $value;
|
||||
$ipoints[] = ['x' => $x, 'y' => $y];
|
||||
} else {
|
||||
$x = $value;
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
|
||||
return $ipoints;
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Imagick\Shapes;
|
||||
|
||||
use Intervention\Image\AbstractShape;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Imagick\Color;
|
||||
|
||||
class RectangleShape extends AbstractShape
|
||||
{
|
||||
/**
|
||||
* X-Coordinate of top-left point
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $x1 = 0;
|
||||
|
||||
/**
|
||||
* Y-Coordinate of top-left point
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $y1 = 0;
|
||||
|
||||
/**
|
||||
* X-Coordinate of bottom-right point
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $x2 = 0;
|
||||
|
||||
/**
|
||||
* Y-Coordinate of bottom-right point
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $y2 = 0;
|
||||
|
||||
/**
|
||||
* Create new rectangle shape instance
|
||||
*
|
||||
* @param int $x1
|
||||
* @param int $y1
|
||||
* @param int $x2
|
||||
* @param int $y2
|
||||
*/
|
||||
public function __construct($x1 = null, $y1 = null, $x2 = null, $y2 = null)
|
||||
{
|
||||
$this->x1 = is_numeric($x1) ? intval($x1) : $this->x1;
|
||||
$this->y1 = is_numeric($y1) ? intval($y1) : $this->y1;
|
||||
$this->x2 = is_numeric($x2) ? intval($x2) : $this->x2;
|
||||
$this->y2 = is_numeric($y2) ? intval($y2) : $this->y2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw rectangle to given image at certain position
|
||||
*
|
||||
* @param Image $image
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @return boolean
|
||||
*/
|
||||
public function applyToImage(Image $image, $x = 0, $y = 0)
|
||||
{
|
||||
$rectangle = new \ImagickDraw;
|
||||
|
||||
// set background
|
||||
$bgcolor = new Color($this->background);
|
||||
$rectangle->setFillColor($bgcolor->getPixel());
|
||||
|
||||
// set border
|
||||
if ($this->hasBorder()) {
|
||||
$border_color = new Color($this->border_color);
|
||||
$rectangle->setStrokeWidth($this->border_width);
|
||||
$rectangle->setStrokeColor($border_color->getPixel());
|
||||
}
|
||||
|
||||
$rectangle->rectangle($this->x1, $this->y1, $this->x2, $this->y2);
|
||||
|
||||
$image->getCore()->drawImage($rectangle);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user