コード例 #1
0
ファイル: Image.php プロジェクト: ponydevs/MLPVC-RR
 /**
  * Draw a an (optionally filled) circle on an $image
  *
  * @param resource   $image
  * @param int        $x
  * @param int        $y
  * @param int|array  $size
  * @param string     $fill
  * @param string|int $outline
  */
 static function drawCircle($image, $x, $y, $size, $fill, $outline)
 {
     if (!empty($fill)) {
         $fill = CoreUtils::hex2Rgb($fill);
         $fill = imagecolorallocate($image, $fill[0], $fill[1], $fill[2]);
     }
     if (is_string($outline)) {
         $outline = CoreUtils::hex2Rgb($outline);
         $outline = imagecolorallocate($image, $outline[0], $outline[1], $outline[2]);
     }
     if (is_array($size)) {
         $width = $size[0];
         $height = $size[1];
         $x2 = $x + $width;
         $y2 = $y + $height;
     } else {
         $x2 = $x + $size;
         $y2 = $y + $size;
         $width = $height = $size;
     }
     $cx = CoreUtils::average($x, $x2);
     $cy = CoreUtils::average($y, $y2);
     if (isset($fill)) {
         imagefilledellipse($image, $cx, $cy, $width, $height, $fill);
     }
     imageellipse($image, $cx, $cy, $width, $height, $outline);
 }