Upgrade to 4.2.0
This commit is contained in:
@@ -1616,12 +1616,12 @@ class SimpleImage
|
||||
* @param int $width The ellipse width.
|
||||
* @param int $height The ellipse height.
|
||||
* @param string|array $color The ellipse color.
|
||||
* @param int|array $thickness Line thickness in pixels or 'filled' (default 1).
|
||||
* @param string|int|array $thickness Line thickness in pixels or 'filled' (default 1).
|
||||
* @return SimpleImage
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function ellipse(int $x, int $y, int $width, int $height, string|array $color, int|array $thickness = 1): static
|
||||
public function ellipse(int $x, int $y, int $width, int $height, string|array $color, string|int|array $thickness = 1): static
|
||||
{
|
||||
// Allocate the color
|
||||
$tempColor = $this->allocateColor($color);
|
||||
@@ -2337,18 +2337,24 @@ class SimpleImage
|
||||
$hex = strval(preg_replace('/^#/', '', $color));
|
||||
|
||||
// Support short and standard hex codes
|
||||
if (strlen($hex) === 3) {
|
||||
if (strlen($hex) === 3 || strlen($hex) === 4) {
|
||||
[$red, $green, $blue] = [
|
||||
$hex[0].$hex[0],
|
||||
$hex[1].$hex[1],
|
||||
$hex[2].$hex[2],
|
||||
];
|
||||
} elseif (strlen($hex) === 6) {
|
||||
if (strlen($hex) === 4) {
|
||||
$alpha = hexdec($hex[3]) / 255;
|
||||
}
|
||||
} elseif (strlen($hex) === 6 || strlen($hex) === 8) {
|
||||
[$red, $green, $blue] = [
|
||||
$hex[0].$hex[1],
|
||||
$hex[2].$hex[3],
|
||||
$hex[4].$hex[5],
|
||||
];
|
||||
if (strlen($hex) === 8) {
|
||||
$alpha = hexdec($hex[6].$hex[7]) / 255;
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Invalid color value: $color", self::ERR_INVALID_COLOR);
|
||||
}
|
||||
|
Reference in New Issue
Block a user