Пример #1
0
 /**
  * Add text to image
  * @param $text
  * @param int $size
  * @param int $x
  * @param int $y
  * @param string $color
  * @param int $alpha
  * @return Editor Instance of Editor
  */
 public function text($text, $size = 4, $x = 0, $y = 0, $color = '#000000', $alpha = 0)
 {
     list($r, $g, $b) = $this->colorConverter->hexToRgb($color);
     $colorResource = imagecolorallocatealpha($this->image->getImageResource(), $r, $g, $b, $alpha);
     imagestring($this->image->getImageResource(), $size, $x, $y, $text, $colorResource);
     return $this;
 }
Пример #2
0
 public function testHexToRgb()
 {
     $colorConverter = new ColorConverter();
     list($r, $g, $b) = $colorConverter->hexToRgb('#ffffff');
     // White
     $this->assertEquals(255, $r);
     $this->assertEquals(255, $g);
     $this->assertEquals(255, $b);
     list($r, $g, $b) = $colorConverter->hexToRgb('#000000');
     // Black
     $this->assertEquals(0, $r);
     $this->assertEquals(0, $g);
     $this->assertEquals(0, $b);
     list($r, $g, $b) = $colorConverter->hexToRgb('#ff0000');
     // Red
     $this->assertEquals(255, $r);
     $this->assertEquals(0, $g);
     $this->assertEquals(0, $b);
 }