17 $points = $this->
argument(0)->type(
'array')->required()->value();
18 $callback = $this->
argument(1)->type(
'closure')->value();
20 $vertices_count = count($points);
23 if ($vertices_count % 2 !== 0) {
24 throw new \Intervention\Image\Exception\InvalidArgumentException(
25 "The number of given polygon vertices must be even."
29 if ($vertices_count < 6) {
30 throw new \Intervention\Image\Exception\InvalidArgumentException(
31 "You must have at least 3 points in your array."
35 $polygon_classname = sprintf(
'\Intervention\Image\%s\Shapes\PolygonShape',
36 $image->getDriver()->getDriverName());
38 $polygon =
new $polygon_classname($points);
40 if ($callback instanceof Closure) {
44 $polygon->applyToImage($image);