Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 71eae08

Browse files
committed
Warn on non-opaque colors for problems
1 parent eb0c241 commit 71eae08

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎webapp/src/Utils/Utils.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,16 @@ public static function convertToColor(string $hex): ?string
350350
public static function parseHexColor(string $hex): array
351351
{
352352
// Source: https://stackoverflow.com/a/21966100
353-
$length = (strlen($hex) - 1) / 3;
353+
$length = (strlen($hex) - 1) / 4;
354+
if (((strlen($hex) - 1) % 3) == 0) {
355+
$length = (strlen($hex) - 1) / 3;
356+
}
354357
$fact = [17, 1, 0.062272][$length - 1];
355358
return [
356359
(int)round(hexdec(substr($hex, 1, $length)) * $fact),
357360
(int)round(hexdec(substr($hex, 1 + $length, $length)) * $fact),
358-
(int)round(hexdec(substr($hex, 1 + 2 * $length, $length)) * $fact)
361+
(int)round(hexdec(substr($hex, 1 + 2 * $length, $length)) * $fact),
362+
(int)round(hexdec(substr($hex, 1 + 3 * $length, $length)) * $fact)
359363
];
360364
}
361365

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /