mirror of
https://github.com/Intervention/image.git
synced 2025-08-22 13:32:56 +02:00
added fill method
This commit is contained in:
@@ -283,6 +283,43 @@ class Image
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill image with given hexadecimal color at position x,y
|
||||||
|
*
|
||||||
|
* @param string $color
|
||||||
|
* @param integer $pos_x
|
||||||
|
* @param integer $pos_y
|
||||||
|
* @return Image
|
||||||
|
*/
|
||||||
|
public function fill($color, $pos_x = 0, $pos_y = 0)
|
||||||
|
{
|
||||||
|
imagefill($this->resource, $pos_x, $pos_y, $this->getColor($color));
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set single pixel
|
||||||
|
*
|
||||||
|
* @param string $color
|
||||||
|
* @param integer $pos_x
|
||||||
|
* @param integer $pos_y
|
||||||
|
* @return Image
|
||||||
|
*/
|
||||||
|
public function pixel($color, $pos_x = 0, $pos_y = 0)
|
||||||
|
{
|
||||||
|
imagesetpixel($this->resource, $pos_x, $pos_y, $this->getColor($color));
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function text($text, $pos_x = 0, $pos_y = 0, $size = 16, $color = '000000', $fontfile = null, $angle = 0)
|
||||||
|
{
|
||||||
|
$fontfile = is_null($fontfile) ? 'public/ttf/bebas/BEBAS___.TTF' : $fontfile;
|
||||||
|
imagettftext($this->resource, $size, $angle, $pos_x, $pos_y, $this->getColor($color), $fontfile, $text);
|
||||||
|
// imagestring($this->resource, 5, $pos_x, $pos_y, $text, $color);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pixelate current image
|
* Pixelate current image
|
||||||
*
|
*
|
||||||
@@ -361,6 +398,27 @@ class Image
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocate color from given string
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function getColor($hexcolor)
|
||||||
|
{
|
||||||
|
// $args = func_get_args();
|
||||||
|
|
||||||
|
$value = (string) $value;
|
||||||
|
|
||||||
|
$color = array(
|
||||||
|
'r' => '0x' . substr($value, 0, 2),
|
||||||
|
'g' => '0x' . substr($value, 2, 2),
|
||||||
|
'b' => '0x' . substr($value, 4, 2)
|
||||||
|
);
|
||||||
|
|
||||||
|
return imagecolorallocate($this->resource, $color['r'], $color['g'], $color['b']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save image in filesystem
|
* Save image in filesystem
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user