ColourCodes: Fixing handling on RGB with values > 0 (#4480)
* ColourCode: Rough failing test for #4479; not correct test-case but at least not ffffff * Updating test to be bang-on-accurate * ColourCodes: Fixes #4479master
parent
0ad6de99b1
commit
48a1f3348e
|
@ -70,14 +70,12 @@ handle query_lc => sub {
|
|||
s/\sto\s(?:$typestr)?//g;
|
||||
|
||||
$_ =~ $trigger_and_guard;
|
||||
|
||||
$type = lc $+{'type'} if defined $+{'type'} and exists $types{lc $+{'type'}};
|
||||
$type = $types{lc $+{'type'}} if defined $+{'type'} and exists $types{lc $+{'type'}};
|
||||
|
||||
$color = "$+{'r'} $+{'g'} $+{'b'}" if defined $+{'r'} and defined $+{'g'} and defined $+{'b'};
|
||||
$color = lc $+{'color'} if defined $+{'color'};
|
||||
|
||||
$inverse = 1 if defined $+{'inv'};
|
||||
|
||||
$color =~ s/,?\s+/,/g;
|
||||
$color =~ s/([0-9]+,[0-9]+,[0-9]+),([0]?\.[0-9]+)/$alpha = $2; $1/e;
|
||||
|
||||
|
@ -92,7 +90,6 @@ handle query_lc => sub {
|
|||
}
|
||||
|
||||
my $col = try { Convert::Color->new("$type:$color") };
|
||||
|
||||
return unless $col;
|
||||
|
||||
if ($inverse) {
|
||||
|
|
|
@ -110,6 +110,10 @@ ddg_goodie_test(
|
|||
'Hex: #633CB0 ~ RGBA(99, 60, 176, 1) ~ RGB(39%, 24%, 69%) ~ HSL(260, 49%, 46%) ~ CMYB(44%, 66%, 0%, 31%)'."\n".'Complementary: #89B03C'."\n".'Analogous: #9D3CB0, #3C4FB0',
|
||||
%basic_answer
|
||||
),
|
||||
'rgb(217,37,50)' => test_zci(
|
||||
'Hex: #D92532 ~ RGBA(217, 37, 50, 1) ~ RGB(85%, 15%, 20%) ~ HSL(356, 71%, 50%) ~ CMYB(0%, 83%, 77%, 15%)'."\n".'Complementary: #25D9CD'."\n".'Analogous: #D97325, #D9258B',
|
||||
%basic_answer
|
||||
),
|
||||
# Check the content of the structured answer. Just once.
|
||||
'hsl 194 0.53 0.79' => test_zci(
|
||||
'Hex: #ADD8E5 ~ RGBA(173, 216, 229, 1) ~ RGB(68%, 85%, 90%) ~ HSL(194, 53%, 79%) ~ CMYB(25%, 6%, 0%, 10%)'."\n".'Complementary: #E6BBAE'."\n".'Analogous: #AEBDE6, #AEE6D7',
|
||||
|
|
Loading…
Reference in New Issue