Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2017-08-01 20:09:07 +0300
committerJulius Härtl <jus@bitgrid.net>2017-08-01 20:09:07 +0300
commit9cd21bbe8a890a6561885200d9bd297657e67bcc (patch)
tree366b9318d0bfd92278f0931e48eecda4d72ce45b /apps/theming/lib/Util.php
parent84c22fdeef6986f9038d8563937cc234751d5147 (diff)
Use same lightness calculation as the SCSS compiler for theming
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/theming/lib/Util.php')
-rw-r--r--apps/theming/lib/Util.php11
1 files changed, 7 insertions, 4 deletions
diff --git a/apps/theming/lib/Util.php b/apps/theming/lib/Util.php
index 1df16ea4976..f0e8fd92ca8 100644
--- a/apps/theming/lib/Util.php
+++ b/apps/theming/lib/Util.php
@@ -30,6 +30,7 @@ use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\IConfig;
use OCP\Files\IRootFolder;
+use Leafo\ScssPhp\Compiler;
class Util {
@@ -95,10 +96,12 @@ class Util {
if (strlen($hex) !== 6) {
return 0;
}
- $r = hexdec(substr($hex, 0, 2));
- $g = hexdec(substr($hex, 2, 2));
- $b = hexdec(substr($hex, 4, 2));
- return (0.299 * $r + 0.587 * $g + 0.114 * $b)/255;
+ $red = hexdec(substr($hex, 0, 2));
+ $green = hexdec(substr($hex, 2, 2));
+ $blue = hexdec(substr($hex, 4, 2));
+ $compiler = new Compiler();
+ $hsl = $compiler->toHSL($red, $green, $blue);
+ return $hsl[3]/100;
}
/**