From 45b3e55e660aac661f98fbb3a58b41ab3736851c Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 14 Jul 2021 20:24:37 +0200 Subject: [PATCH] add method getColorBrightness() --- inc/inc.Utils.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/inc/inc.Utils.php b/inc/inc.Utils.php index 2cf0b1708..8f7488723 100644 --- a/inc/inc.Utils.php +++ b/inc/inc.Utils.php @@ -922,6 +922,14 @@ function getMandatoryApprovers($folder, $user) { /* {{{ */ return $approvers; } /* }}} */ +function getColorBrightness($color) { /* {{{ */ + $red = hexdec(substr($color, 1, 2))/255.0; + $green = hexdec(substr($color, 3, 2))/255.0; + $blue = hexdec(substr($color, 5, 2))/255.0; + $brightness = sqrt(0.299*pow($red, 2) + 0.587*pow($green, 2) + 0.114*pow($blue, 2)); + return $brightness; +} /* }}} */ + /** * Class for creating encrypted api keys *