public static function PHPExcel_Style_Color::changeBrightness in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Style/Color.php \PHPExcel_Style_Color::changeBrightness()
* Adjust the brightness of a color * *
Parameters
string $hex The colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE): * @param float $adjustPercentage The percentage by which to adjust the colour as a float from -1 to 1 * @return string The adjusted colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE)
1 call to PHPExcel_Style_Color::changeBrightness()
- PHPExcel_Reader_Excel2007::_readColor in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Reader/ Excel2007.php
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Style/ Color.php, line 300
Class
- PHPExcel_Style_Color
- PHPExcel_Style_Color
Code
public static function changeBrightness($hex, $adjustPercentage) {
$rgba = strlen($hex) == 8;
$red = self::getRed($hex, FALSE);
$green = self::getGreen($hex, FALSE);
$blue = self::getBlue($hex, FALSE);
if ($adjustPercentage > 0) {
$red += (255 - $red) * $adjustPercentage;
$green += (255 - $green) * $adjustPercentage;
$blue += (255 - $blue) * $adjustPercentage;
}
else {
$red += $red * $adjustPercentage;
$green += $green * $adjustPercentage;
$blue += $blue * $adjustPercentage;
}
if ($red < 0) {
$red = 0;
}
elseif ($red > 255) {
$red = 255;
}
if ($green < 0) {
$green = 0;
}
elseif ($green > 255) {
$green = 255;
}
if ($blue < 0) {
$blue = 0;
}
elseif ($blue > 255) {
$blue = 255;
}
$rgb = strtoupper(str_pad(dechex($red), 2, '0', 0) . str_pad(dechex($green), 2, '0', 0) . str_pad(dechex($blue), 2, '0', 0));
return ($rgba ? 'FF' : '') . $rgb;
}