gdAlpha() public static method

Convert alpha value of 0 - 1 to GD compatible alpha value of 0 - 127 where 0 is opaque and 127 is transparent
public static gdAlpha ( float $alpha ) : integer
$alpha float Alpha value of 0 - 1. Example: 0, 0.60, 0.9, 1
return integer
Ejemplo n.º 1
0
 /**
  * TODO: Anti-aliased curves
  * @param ImageInterface $image
  * @return ImageInterface
  */
 public function draw($image)
 {
     list($x, $y) = $this->pos;
     $left = $x + $this->width / 2;
     $top = $y + $this->height / 2;
     if (null !== $this->fillColor) {
         list($r, $g, $b, $alpha) = $this->fillColor->getRgba();
         $fillColorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, Editor::gdAlpha($alpha));
         imagefilledellipse($image->getCore(), $left, $top, $this->width, $this->height, $fillColorResource);
     }
     // Create borders. It will be placed on top of the filled ellipse (if present)
     if (0 < $this->getBorderSize() and null !== $this->borderColor) {
         // With border > 0 AND borderColor !== null
         list($r, $g, $b, $alpha) = $this->borderColor->getRgba();
         $borderColorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, Editor::gdAlpha($alpha));
         imageellipse($image->getCore(), $left, $top, $this->width, $this->height, $borderColorResource);
     }
     return $image;
 }
Ejemplo n.º 2
0
 public function draw($image)
 {
     $x1 = $this->pos[0];
     $x2 = $x1 + $this->getWidth();
     $y1 = $this->pos[1];
     $y2 = $y1 + $this->getHeight();
     if (null !== $this->fillColor) {
         list($r, $g, $b, $alpha) = $this->fillColor->getRgba();
         $fillColorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, Editor::gdAlpha($alpha));
         imagefilledrectangle($image->getCore(), $x1, $y1, $x2, $y2, $fillColorResource);
     }
     // Create borders. It will be placed on top of the filled rectangle (if present)
     if (0 < $this->getBorderSize() and null !== $this->borderColor) {
         // With border > 0 AND borderColor !== null
         list($r, $g, $b, $alpha) = $this->borderColor->getRgba();
         $borderColorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, Editor::gdAlpha($alpha));
         imagerectangle($image->getCore(), $x1, $y1, $x2, $y2, $borderColorResource);
     }
     return $image;
 }
Ejemplo n.º 3
0
 public function draw($image)
 {
     if (function_exists('imageantialias')) {
         imageantialias($image->getCore(), true);
     }
     $points = $this->points();
     $count = count($this->points);
     // Create filled polygon
     if (null !== $this->fillColor) {
         list($r, $g, $b, $alpha) = $this->getFillColor()->getRgba();
         $fillColorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, Editor::gdAlpha($alpha));
         imagefilledpolygon($image->getCore(), $points, $count, $fillColorResource);
     }
     // Create polygon borders. It will be placed on top of the filled polygon (if present)
     if (0 < $this->getBorderSize() and null !== $this->borderColor) {
         // With border > 0 AND borderColor !== null
         list($r, $g, $b, $alpha) = $this->getBorderColor()->getRgba();
         $borderColorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, Editor::gdAlpha($alpha));
         imagepolygon($image->getCore(), $points, $count, $borderColorResource);
     }
     return $image;
 }