From 796f0f93336f3a6d7b954f0c673bec04a3e17147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 1 Aug 2017 18:09:07 +0100 Subject: Use same lightness calculation as the SCSS compiler for theming MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/theming/lib/Util.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/theming/lib/Util.php b/apps/theming/lib/Util.php index 286756a4849..e5fa90cb344 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; } /** -- cgit v1.2.3