in reply to Re: Re: Hex color degrader
in thread Hex color degrader

Not a bad point, but I'd stick to having a brightness value passed, not a scaling factor. It's a bit easier to have a rough idea of the outcome that way IMO.
sub add_to_hexrgb { my @rgb = map hex, unpack "A2"x3, $_[0]; my $max = (sort {$a <=> $b} @rgb)[-1]; my $smax = $max + $_[1]; return $smax < 0 ? "000000" : $smax > 255 ? "FFFFFF" : do { my $fact = ($max + $sumd) / $max; sprintf "%02X"x3, map { int($_ * $fact) } @rgb }; }

Makeshifts last the longest.