sub bestLightnessForHue {
my ( $h, $s ) = @_;
- my $targetContrast = 4.07;
- my $white = Color::sRGB->WHITE;
+ my $targetContrast = $opt_night ? 5.16 : 4.07;
+ my $white = $opt_night ? Color::sRGB->BLACK : Color::sRGB->WHITE;
my $bestLightness;
my $bestContrast;
for ( my $l = 0; $l < 1; $l += 0.002 ) {
# linear interpolation
#my $l1 = $y0 + 1.0 * ( $hue - $x0 ) * ( $y1 - $y0 ) / ( $x1 - $x0 );
my $l1 = bestLightnessForHue( $hue / 360.0, $S );
+ #$l1 += ( 1 - $l1 ) * 0.20 if $opt_night;
- my $l2 = $l1 * 0.80;
- my $l3 = $opt_night ? 0.150 : 0.950;
- my $l4 = $opt_night ? 0.100 : 0.980;
+ #my $l2 = $opt_night ? ( $l1 + ( 1 - $l1 ) * 0.15 ) : $l1 * 0.85;
+ my $l2 = $l1 * 0.80;
+ my $l3 = $opt_night ? 0.150 : 0.950;
+ my $l4 = $opt_night ? 0.100 : 0.980;
my $result = "";
my $indent = "$baseIndent ";
$result .= sprintf "$indent<item name=\"%s\">#00%s</item>\n",
'colorPrimaryTransparent', hslHex( $hue, $S, $l1 );
$result .= sprintf "$indent<item name=\"%s\">#%s</item>\n",
- 'colorSecondary', hslHex( $hue, $S, $l2 );
+ 'colorSecondary', hslHex( $hue, $S, $l1 );
$result .= sprintf "$indent<item name=\"%s\">#%s</item>\n",
- 'colorPrimaryDark', hslHex( $hue, $S, $l2 );
+ 'colorPrimaryDark', hslHex( $hue, $S*0.8, $l2 );
$result .= sprintf "$indent<item name=\"%s\">#%s</item>\n",
'table_row_dark_bg', hslHex( $hue, $S, $l3 );
$result .= sprintf "$indent<item name=\"%s\">#%s</item>\n",