_color_pack: define variable before using

This commit is contained in:
Andrew Dolgov 2021-02-06 09:29:31 +03:00
parent a544123b59
commit 8b39e6bca7
1 changed files with 1 additions and 0 deletions

View File

@ -216,6 +216,7 @@ function _color_unpack($hex, $normalize = false) {
### Convert an RGB triplet to a hex color. ### Convert an RGB triplet to a hex color.
function _color_pack($rgb, $normalize = false) { function _color_pack($rgb, $normalize = false) {
$out = 0;
foreach ($rgb as $k => $v) { foreach ($rgb as $k => $v) {
$out |= (($v * ($normalize ? 255 : 1)) << (16 - $k * 8)); $out |= (($v * ($normalize ? 255 : 1)) << (16 - $k * 8));
}return '#'. str_pad(dechex($out), 6, 0, STR_PAD_LEFT); }return '#'. str_pad(dechex($out), 6, 0, STR_PAD_LEFT);