Help for this page

Select Code to Download


  1. or download this
    $c1 = [ $r, $g, $b ];
    $c2 = contrasting_colour( @c1 );
    ...
                             255 - $c->[2] );
       return sprintf "#%02X%02X%02X",  $r, $g, $b;
    }
    
  2. or download this
    sub contrasting_colour {
       my ( $c ) = @_;
    ...
                             ($c->[2] + 128) % 256,  );
       return [ $r, $g, $b ];
    }