Пример #1
0
 public function testFullParamValues()
 {
     $rectangle = new Rectangle(200, 100, "#ff0000", "#000000", 5);
     $this->assertEquals(200, $rectangle->getWidth());
     $this->assertEquals(100, $rectangle->getHeight());
     $this->assertEquals("#ff0000", $rectangle->getFillColor());
     $this->assertEquals("#000000", $rectangle->getBorderColor());
     $this->assertEquals(5, $rectangle->getBorderSize());
 }
Пример #2
0
 /**
  * Add a rectangle
  * @param Rectangle $rectangle
  * @param int $x Optional. Position on the X axis.
  * @param int $y Optional. Position on the Y axis.
  * @return Editor Instance of Editor
  */
 public function addRectangle(Rectangle $rectangle, $x = 0, $y = 0)
 {
     $alpha = 0;
     // TODO: Make this editable in the future
     $width = $rectangle->getWidth();
     $height = $rectangle->getHeight();
     $borderSize = $rectangle->getBorderSize();
     list($r, $g, $b) = $this->colorConverter->hexToRgb($rectangle->getFillColor());
     $fillColorResource = imagecolorallocatealpha($this->image->getImageResource(), $r, $g, $b, $alpha);
     $x1 = $x;
     $x2 = $x + $width;
     $y1 = $y;
     $y2 = $y + $height;
     if ($borderSize == 0) {
         imagefilledrectangle($this->image->getImageResource(), $x1, $y1, $x2, $y2, $fillColorResource);
     } else {
         list($r, $g, $b) = $this->colorConverter->hexToRgb($rectangle->getBorderColor());
         $borderColorResource = imagecolorallocatealpha($this->image->getImageResource(), $r, $g, $b, $alpha);
         imagefilledrectangle($this->image->getImageResource(), $x1, $y1, $x2, $y2, $borderColorResource);
         imagefilledrectangle($this->image->getImageResource(), $x1 + $borderSize, $y1 + $borderSize, $x2 - $borderSize, $y2 - $borderSize, $fillColorResource);
     }
     return $this;
 }