From 9247d7cadffce430f090c2714b93a6ece1d847d4 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 12 Jun 2024 11:03:11 +0200 Subject: [PATCH] TimeGrid\Util: Enhance entry color variation, somewhat I'm still not convinced that this is good enough. --- library/Notifications/Widget/TimeGrid/Util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Notifications/Widget/TimeGrid/Util.php b/library/Notifications/Widget/TimeGrid/Util.php index d242f0c5..cd7e859f 100644 --- a/library/Notifications/Widget/TimeGrid/Util.php +++ b/library/Notifications/Widget/TimeGrid/Util.php @@ -72,7 +72,7 @@ public static function calculateEntryColor(string $text, int $transparency): str // so if 500 thousand colors of these 16.7 millions are so similar that we can't distinguish them, // there's no need for such a high variance. Hence we'd still need to partition the colors in a way // that they are distinct enough. - $hash = hexdec(hash('sha256', $text)); + $hash = hexdec(substr(hash('sha256', $text), 28, 8)); // Limit the hue to a maximum of 360 as it's HSL's maximum of 360 degrees $h = (int) fmod($hash, 359.0); // TODO: Check if 359 is really of advantage here, instead of 360 // The hue is already at least 1 degree off to every other, using a limited set of saturation values