Esempio n. 1
0
 /**
  * Image
  *
  * Used to build the actual image resource.
  *
  * @access	public
  * @return	image resource for final rounded corner
  */
 public function image()
 {
     $this->image = imagecreatetruecolor($this->radius, $this->radius);
     imagealphablending($this->image, !$this->bgtransparent);
     $rgb = new Rounded_RGB($this->bgtransparent ? !$this->btransparent && $this->borderwidth > 0 ? $this->bordercolor : $this->foreground : $this->background);
     $color = imagecolorallocatealpha($this->image, $rgb->red, $rgb->green, $rgb->blue, $this->bgtransparent ? 127 : 0);
     imagefilledrectangle($this->image, 0, 0, $this->radius - 1, $this->radius - 1, $color);
     if ($this->bgtransparent && ($this->btransparent || $this->borderwidth == 0) && ($this->fgtransparent || $this->borderwidth >= $this->radius)) {
         return $this->image;
     }
     if ($this->borderwidth > 0 && !($this->bgtransparent && $this->btransparent)) {
         imagealphablending($this->image, !$this->btransparent);
         $rgb = new Rounded_RGB($this->btransparent ? $this->background : $this->bordercolor);
         $this->draw($this->radius, $rgb, $this->antialias, $this->btransparent);
     }
     if ($this->borderwidth < $this->radius && !($this->fgtransparent && $this->btransparent && $this->borderwidth > 0)) {
         if ($this->borderwidth > 0 && $this->btransparent) {
             imagealphablending($this->image, false);
             $rgb = new Rounded_RGB('FFF');
             $this->draw($this->radius - $this->borderwidth, $rgb, false);
         }
         imagealphablending($this->image, !($this->fgtransparent || $this->btransparent && $this->borderwidth > 0));
         $rgb = new Rounded_RGB($this->fgtransparent ? !$this->btransparent && $this->borderwidth > 0 ? $this->bordercolor : $this->background : $this->foreground);
         $this->draw($this->radius - $this->borderwidth, $rgb, $this->antialias, $this->fgtransparent);
     }
     switch ($this->orientation) {
         case 'br':
         case 'rb':
             break;
         case 'bl':
         case 'lb':
             $this->image = Rounded_Tools::imageFlipHorizontal($this->image);
             break;
         case 'tr':
         case 'rt':
             $this->image = Rounded_Tools::imageFlipVertical($this->image);
             break;
         case 'tl':
         case 'lt':
         default:
             $this->image = Rounded_Tools::imageFlipBoth($this->image);
             break;
     }
     return $this->image;
 }
Esempio n. 2
0
 /**
  * ImageFlipBoth
  *
  * Flip an image both horizontally and vertically
  *
  * @access	public static
  * @param	image	$old	image resource for original image
  * @return	image			image resource for altered image
  */
 public static function imageFlipBoth($old)
 {
     return Rounded_Tools::imageFlipHorizontal(Rounded_Tools::imageFlipVertical($old));
 }
Esempio n. 3
0
 /**
  * Image
  *
  * Used to build the actual image resource.
  *
  * @access	public
  * @return	image resource for rounded rectangle side
  */
 public function image()
 {
     $this->image = imagecreatetruecolor($this->width, $this->height);
     imagealphablending($this->image, !($this->bgtransparent || $this->btransparent || $this->fgtransparent));
     $rgb = new Rounded_RGB($this->foreground);
     $color = imagecolorallocatealpha($this->image, $rgb->red, $rgb->green, $rgb->blue, $this->fgtransparent ? 127 : 0);
     imagefilledrectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $color);
     if ($this->borderwidth > 0) {
         $rgb = new Rounded_RGB($this->bordercolor);
         $color = imagecolorallocatealpha($this->image, $rgb->red, $rgb->green, $rgb->blue, $this->btransparent ? 127 : 0);
         switch ($this->side) {
             case 'l':
             case 'left':
                 imagefilledrectangle($this->image, 0, 0, $this->borderwidth - 1, $this->height - 1, $color);
                 break;
             case 'r':
             case 'right':
                 imagefilledrectangle($this->image, $this->width - $this->borderwidth, 0, $this->width - 1, $this->height - 1, $color);
                 break;
             case 'b':
             case 'bottom':
                 imagefilledrectangle($this->image, 0, $this->height - $this->borderwidth, $this->width - 1, $this->height - 1, $color);
                 break;
             case 't':
             case 'top':
             default:
                 imagefilledrectangle($this->image, 0, 0, $this->width - 1, $this->borderwidth - 1, $color);
                 break;
         }
     }
     $params = array('radius' => $this->radius, 'orientation' => 'tl', 'foreground' => $this->foreground, 'background' => $this->background, 'borderwidth' => $this->borderwidth, 'bordercolor' => $this->bordercolor, 'bgtransparent' => $this->bgtransparent, 'btransparent' => $this->btransparent, 'fgtransparent' => $this->fgtransparent, 'antialias' => $this->antialias);
     $img = Rounded_Corner::create($params);
     if ($this->side == 't' || $this->side == 'top' || $this->side == 'l' || $this->side == 'left') {
         imagecopy($this->image, $img, 0, 0, 0, 0, $this->radius, $this->radius);
     }
     $img = Rounded_Tools::imageFlipVertical($img);
     if ($this->side == 'l' || $this->side == 'left' || $this->side == 'b' || $this->side == 'bottom') {
         imagecopy($this->image, $img, 0, $this->height - $this->radius, 0, 0, $this->radius, $this->radius);
     }
     $img = Rounded_Tools::imageFlipHorizontal($img);
     if ($this->side == 'b' || $this->side == 'bottom' || $this->side == 'r' || $this->side == 'right') {
         imagecopy($this->image, $img, $this->width - $this->radius, $this->height - $this->radius, 0, 0, $this->radius, $this->radius);
     }
     $img = Rounded_Tools::imageFlipVertical($img);
     if ($this->side == 'r' || $this->side == 'right' || $this->side == 't' || $this->side == 'top') {
         imagecopy($this->image, $img, $this->width - $this->radius, 0, 0, 0, $this->radius, $this->radius);
     }
     return $this->image;
 }
Esempio n. 4
0
 /**
  * Image
  *
  * Used to build the actual image resource.
  *
  * @access	public
  * @return	image resource for rounded rectangle
  */
 public function image()
 {
     $this->image = imagecreatetruecolor($this->width, $this->height);
     imagealphablending($this->image, !($this->bgtransparent || $this->btransparent || $this->fgtransparent));
     $rgb = new Rounded_RGB($this->bordercolor);
     $color = imagecolorallocatealpha($this->image, $rgb->red, $rgb->green, $rgb->blue, $this->borderwidth == 0 || $this->btransparent ? 127 : 0);
     imagefilledrectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $color);
     if ($this->borderwidth < min($this->width, $this->height) / 2) {
         $rgb = new Rounded_RGB($this->foreground);
         $color = imagecolorallocatealpha($this->image, $rgb->red, $rgb->green, $rgb->blue, $this->fgtransparent ? 127 : 0);
         imagefilledrectangle($this->image, $this->borderwidth, $this->borderwidth, $this->width - $this->borderwidth - 1, $this->height - $this->borderwidth - 1, $color);
     }
     $params = array('radius' => $this->radius, 'orientation' => 'tl', 'foreground' => $this->foreground, 'background' => $this->background, 'borderwidth' => $this->borderwidth, 'bordercolor' => $this->bordercolor, 'bgtransparent' => $this->bgtransparent, 'btransparent' => $this->btransparent, 'fgtransparent' => $this->fgtransparent, 'antialias' => $this->antialias);
     $img = Rounded_Corner::create($params);
     imagecopy($this->image, $img, 0, 0, 0, 0, $this->radius, $this->radius);
     $img = Rounded_Tools::imageFlipVertical($img);
     imagecopy($this->image, $img, 0, $this->height - $this->radius, 0, 0, $this->radius, $this->radius);
     $img = Rounded_Tools::imageFlipHorizontal($img);
     imagecopy($this->image, $img, $this->width - $this->radius, $this->height - $this->radius, 0, 0, $this->radius, $this->radius);
     $img = Rounded_Tools::imageFlipVertical($img);
     imagecopy($this->image, $img, $this->width - $this->radius, 0, 0, 0, $this->radius, $this->radius);
     imagedestroy($img);
     return $this->image;
 }
Esempio n. 5
0
 function rounded($file, $radius)
 {
     # Require Corner, RGB and Tools classes
     require_once 'Rounded/RGB.php';
     require_once 'Rounded/Corner.php';
     require_once 'Rounded/Tools.php';
     $params = array('radius' => $radius, 'orientation' => 'tl', 'foreground' => 0, 'background' => 'fff', 'borderwidth' => 0, 'bordercolor' => 0, 'bgtransparent' => false, 'fgtransparent' => true, 'btransparent' => true, 'antialias' => true);
     if ($file) {
         if (is_string($file)) {
             $image = imagecreatefromstring(file_get_contents($file));
         } elseif (is_resource($file)) {
             $image =& $file;
         }
         $img = Rounded_Corner::create($params);
         imagecopy($image, $img, 0, 0, 0, 0, $radius, $radius);
         $img = Rounded_Tools::imageFlipVertical($img);
         imagecopy($image, $img, 0, imagesy($image) - $radius, 0, 0, $radius, $radius);
         $img = Rounded_Tools::imageFlipHorizontal($img);
         imagecopy($image, $img, imagesx($image) - $radius, imagesy($image) - $radius, 0, 0, $radius, $radius);
         $img = Rounded_Tools::imageFlipVertical($img);
         imagecopy($image, $img, imagesx($image) - $radius, 0, 0, 0, $radius, $radius);
         return $image;
     }
 }