File indexing completed on 2025-01-26 05:29:13

0001 <?php
0002 
0003 namespace Intervention\Image\Commands;
0004 
0005 use Closure;
0006 
0007 class CircleCommand extends \Intervention\Image\Commands\AbstractCommand
0008 {
0009     /**
0010      * Draw a circle centered on given image
0011      *
0012      * @param  \Intervention\Image\image $image
0013      * @return boolean
0014      */
0015     public function execute($image)
0016     {
0017         $diameter = $this->argument(0)->type('numeric')->required()->value();
0018         $x = $this->argument(1)->type('numeric')->required()->value();
0019         $y = $this->argument(2)->type('numeric')->required()->value();
0020         $callback = $this->argument(3)->type('closure')->value();
0021 
0022         $circle_classname = sprintf('\Intervention\Image\%s\Shapes\CircleShape',
0023             $image->getDriver()->getDriverName());
0024 
0025         $circle = new $circle_classname($diameter);
0026 
0027         if ($callback instanceof Closure) {
0028             $callback($circle);
0029         }
0030 
0031         $circle->applyToImage($image, $x, $y);
0032 
0033         return true;
0034     }
0035 }