]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use same lightness calculation as the SCSS compiler for theming 5977/head
authorJulius Härtl <jus@bitgrid.net>
Tue, 1 Aug 2017 17:09:07 +0000 (18:09 +0100)
committerJulius Härtl <jus@bitgrid.net>
Fri, 4 Aug 2017 10:13:33 +0000 (12:13 +0200)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
apps/theming/lib/Util.php

index 286756a4849e91f71c3ef5d564f8d14c3049ad66..e5fa90cb344322daaf6226558be07cce79495b54 100644 (file)
@@ -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;
        }
 
        /**