Merge pull request #5984 from nextcloud/stable12-reopen-stable12-theming-lightness-correction

[stable12] Use same lightness calculation as the SCSS compiler for theming
This commit is contained in:
Morris Jobke 2017-08-08 10:40:37 +02:00 committed by GitHub
commit bcea6a041f
1 changed files with 7 additions and 4 deletions

View 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;
}
/**