X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=tools%2Fgen-styles;h=0e894e9f3cb1028644969c80170ac79172c60c19;hb=a13b80a2b4450161adb817165fd5f7a95be72811;hp=21388fe3826d57338a9f9997a82171c27626e42f;hpb=01f62b66cbef1915f20c8b42cab9260efac39498;p=mobile-ledger.git diff --git a/tools/gen-styles b/tools/gen-styles index 21388fe3..0e894e9f 100644 --- a/tools/gen-styles +++ b/tools/gen-styles @@ -163,53 +163,62 @@ my $baseTheme = "AppTheme.NoActionBar"; # HSL sub outputThemes { my $out = shift; - $out->print(hslStyleForHue($baseColorHue)); + my $baseIndent = shift; + $out->print(hslStyleForHue($baseColorHue, undef, $baseIndent)); for( my $hue = 0; $hue < 360; $hue += 15 ) { - $out->print(hslStyleForHue($hue, $baseTheme)); + $out->print("\n"); + $out->print(hslStyleForHue($hue, $baseTheme, $baseIndent)); } } sub hslStyleForHue { my $hue = shift; my $base = shift; + my $baseIndent = shift // ''; my $blueL = 0.665; my $yellowL = 0.350; + my $blueL2 = 0.350; + my $yellowL2 = 0.500; + + # $y == 0 for yellow my $y = $hue - 60; $y += 360 if $y < 0; + # $q == 0 for yellow, 1 for blue my $q = cos(deg2rad(abs($y-180)/2.0)); my $l1 = $yellowL + ($blueL - $yellowL) * $q; - my $l2 = 0.150 + 0.350 * $q; + my $l2 = 0.250 + 0.250 * $q; my $l3 = 0.950; my $l4 = 0.980; my $result = ""; + my $indent = "$baseIndent "; if ($base) { - $result .= sprintf "\n"; + $result .= "$baseIndent\n"; return $result; } @@ -221,16 +230,18 @@ if ($xml) { my $end_marker = ''; my ($fh, $filename) = tempfile(basename($0).'.XXXXXXXX', DIR => dirname($xml)); open(my $in, '<', $xml); + my $base_indent = ''; my $state = 'waiting-for-start-marker'; while (<$in>) { if ( $state eq 'waiting-for-start-marker' ) { print $fh $_; - $state = 'skipping-styles' if /^\s*\Q$start_marker\E/; + $state = 'skipping-styles', $base_indent = $1 + if /^(\s*)\Q$start_marker\E/; next; } if ( $state eq 'skipping-styles' ) { next unless /^\s*\Q$end_marker\E/; - outputThemes($fh); + outputThemes($fh, $base_indent); print $fh $_; $state = 'copying-the-rest'; next;