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
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
You can’t perform that action at this time.
0 commit comments