From 9b4be255e27ea8646e7b4c7817fa477f1d462f51 Mon Sep 17 00:00:00 2001 From: Felix Hahn Date: Thu, 8 Feb 2024 22:04:21 +0100 Subject: [PATCH] fix non-relative lighten() --- helpers/ColorHelper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helpers/ColorHelper.php b/helpers/ColorHelper.php index ae152dc..c6b4fb4 100644 --- a/helpers/ColorHelper.php +++ b/helpers/ColorHelper.php @@ -29,7 +29,7 @@ public static function lighten(string $color, int $amount, bool $relative = fals $max = hexdec(max($color_parts)); $min = hexdec(min($color_parts)); if ($max !=0) { - $percentage = 2 * 255 * $percentage / ( $max + $min ); + $percentage = $percentage / ( 1 - ($max + $min)/(2*255)); } } @@ -88,8 +88,8 @@ public static function fade(string $color, int $amount): string { return $color . $opacity; } - protected static function getColorComponents(string $color): array { - + protected static function getColorComponents(string $color): array + { // Remove leading '#' $hexstr = ltrim($color, '#'); // if color has just 3 digits