Skip to content

Commit 1a1c9aa

Browse files
committed
Fix the UI
1 parent 5981211 commit 1a1c9aa

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

webapp/src/Utils/Utils.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,10 @@ public static function parseHexColor(string $hex): array
352352
$tmp = substr($hex, 1);
353353
if (strlen($tmp) % 3 == 0) {
354354
$mult = strlen($tmp) / 3;
355-
$hex += 'f' * $mult;
355+
$hex .= str_repeat("f", $mult);
356356
}
357357
// Source: https://stackoverflow.com/a/21966100
358-
$length = (strlen($hex) - 1) / 3;
358+
$length = (strlen($hex) - 1) / 4;
359359
$fact = [17, 1, 0.062272][$length - 1];
360360
return [
361361
(int)round(hexdec(substr($hex, 1, $length)) * $fact),
@@ -384,28 +384,28 @@ public static function rgbToHex(array $color): string
384384
$result = "#";
385385
if (count($color) === 3) {
386386
$color[] = 255;
387-
} elseif (count($color) !== 4) {
387+
} elseif (count($color) !== 4) {
388388
throw Exception("Invalid RGB number.");
389-
}
390-
for (int $i=0; $i<count($color); $i++) {
391-
$result += static::componentToHex($color[$i]);
392389
}
390+
for ($i=0; $i<count($color); $i++) {
391+
$result .= static::componentToHex($color[$i]);
392+
}
393393
return $result;
394394
}
395395

396396
/**
397397
* @param array{int, int, int}|array{int, int, int, int} $rgba
398-
* @param array{int, int, int} $bg
399398
*
400399
* @return array{int, int, int}
401400
*/
402-
public static function blendAlphaBackground(array $rgba, array $bg): array
401+
public static function blendAlphaBackground(array $rgba, string $bg): array
403402
{
404403
if (count($rgba) === 3) {
405404
return $rgba;
406405
} elseif (count($rgba) === 4) {
407-
$result = [];
408-
for (int $i=0; $i<3; $i++) {
406+
$result = [];
407+
$bg = static::parseHexColor($bg);
408+
for ($i=0; $i<3; $i++) {
409409
$result[] = $rgba[$i] * $rgba[3] + $bg[$i] * (1 - $rgba[3]);
410410
}
411411
return $result;

0 commit comments

Comments
 (0)