use strict; my $styles = ''; my $map = " \n"; my $steps = 20; my $margin = 15; my $cutoff = 33; my $a = -$margin / (50*50 - 5000); for (my $hue = 0.0; $hue < 360.0; $hue += 360.0/$steps) { $map .= " \n \n $hue\n"; for (my $lightness = 0.0; $lightness <= 100.0; $lightness += 100.0/$steps) { $map .= " $lightness\%\n"; } $map .= " \n"; for (my $saturation = 0.0; $saturation <= 100.0; $saturation += 100.0/$steps) { $map .= " \n $saturation\%\n"; for (my $lightness = 0.0; $lightness <= 100.0; $lightness += 100.0/$steps) { my $code = "h${hue}s${saturation}l${lightness}"; $map .= " abc def\n"; my $color = $lightness - ($a * $saturation * $saturation - $a * 100 * $saturation + $margin) < $cutoff ? 'white' : 'black'; $color = $lightness > 50 ? 'black' : 'white'; $styles .= " #$code { background: hsl($hue, $saturation\%, $lightness\%); color: $color; }\n"; } $map .= " \n"; } $map .= "
\n"; } $map .= "
"; print < ]> Colour Contrast Investigation $map cut