range() 공개 정적인 메소드

If lower, $min is returned. If higher, $max is returned.
public static range ( mixed $value, integer $min, integer $max ) : integer
$value mixed
$min integer
$max integer
리턴 integer
예제 #1
0
파일: Filter.php 프로젝트: JBZoo/Image
 /**
  * Add border to an image
  *
  * @param resource $image  Image GD resource
  * @param array    $params Some
  * @return resource
  * @throws \JBZoo\Utils\Exception
  */
 public static function border($image, array $params = array())
 {
     $params = array_merge(array('color' => '#333', 'size' => 1), $params);
     $size = Helper::range($params['size'], 1, 1000);
     $rgba = Helper::normalizeColor($params['color']);
     $width = imagesx($image);
     $height = imagesy($image);
     $x1 = 0;
     $y1 = 0;
     $x2 = $width - 1;
     $y2 = $height - 1;
     $color = imagecolorallocatealpha($image, $rgba[0], $rgba[1], $rgba[2], $rgba[3]);
     for ($i = 0; $i < $size; $i++) {
         imagerectangle($image, $x1++, $y1++, $x2--, $y2--, $color);
     }
 }