diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2017-08-02 23:17:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-02 23:17:19 +0200 |
commit | ea2e629c6ca307704dea0aed106dfcb8c0bcc559 (patch) | |
tree | 0bf3a38a7cdd1639285df3024b202e336a8de94d /apps/theming | |
parent | c40352c03071740f51544f0fcd7fc787c5c3f27b (diff) | |
parent | 9cd21bbe8a890a6561885200d9bd297657e67bcc (diff) | |
download | nextcloud-server-ea2e629c6ca307704dea0aed106dfcb8c0bcc559.tar.gz nextcloud-server-ea2e629c6ca307704dea0aed106dfcb8c0bcc559.zip |
Merge pull request #5953 from nextcloud/theming-lightness-correction
Use same lightness calculation as the SCSS compiler for theming
Diffstat (limited to 'apps/theming')
-rw-r--r-- | apps/theming/lib/Util.php | 11 |
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; } /** |