Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
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;
     }
 }