File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -350,12 +350,16 @@ public static function convertToColor(string $hex): ?string
350
350
public static function parseHexColor (string $ hex ): array
351
351
{
352
352
// 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
+ }
354
357
$ fact = [17 , 1 , 0.062272 ][$ length - 1 ];
355
358
return [
356
359
(int )round (hexdec (substr ($ hex , 1 , $ length )) * $ fact ),
357
360
(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 )
359
363
];
360
364
}
361
365
You can’t perform that action at this time.
0 commit comments