X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=tools%2Fgen-styles;h=7a22c7e7f1924b8d346d2cfc25a9172f0dad8796;hb=c6d5f4d72d3ca705cc03b04d87b282ebe717bd61;hp=1c2c4c8524af8796d0c35ce33214857f70a3a069;hpb=da3450cd594a3f9ad6f0a76b2b2fc219949a6695;p=mobile-ledger.git
diff --git a/tools/gen-styles b/tools/gen-styles
index 1c2c4c85..7a22c7e7 100644
--- a/tools/gen-styles
+++ b/tools/gen-styles
@@ -1,10 +1,19 @@
#!/usr/bin/perl
-use strict; use warnings; use utf8;
+use strict; use warnings; use utf8::all;
use autodie;
use Math::Trig;
use File::Basename qw(basename dirname);
use File::Temp qw(tempfile);
+use Getopt::Long;
+
+my $opt_night;
+
+GetOptions(
+ 'night!' => \$opt_night,
+) or exit 1;
+
+my $DEFAULT_HUE = 261.2245;
sub hexTuple {
my ($r, $g, $b) = @_;
@@ -84,7 +93,7 @@ sub hexToHSL {
my $hexTriplet = shift;
my ($r,$g,$b) = hexToRGB($hexTriplet);
- warn "$hexTriplet -> $r:$g:$b";
+ #warn "$hexTriplet -> $r:$g:$b";
for ($r, $g, $b ) { $_ = $_ / 255.0 }
@@ -116,11 +125,11 @@ sub hexToHSL {
return( $H, $S, $L );
}
-my $baseColorHSV = [ hexToHSL('#935ff2') ];
+my $baseColor = '#935ff2';
+my $baseColorHSV = [ hexToHSL($baseColor) ];
my $baseColorHue = $baseColorHSV->[0];
-warn sprintf( 'H:%1.4f S:%1.4f V:%1.4f', @$baseColorHSV );
-warn sprintf( 'H:%1.4f S:%1.4f L:%1.4f', hexToHSL('#3e148c') );
-my @target = hexToRGB('#935ff2');
+warn sprintf( '%s â H:%1.4f S:%1.4f V:%1.4f', $baseColor, @$baseColorHSV );
+my @target = hexToRGB($baseColor);
my ($best, $min_dist);
for (my $s = 0.50; $s < 0.90; $s += 0.001) {
for ( my $l = 0.50; $l <= 0.80; $l += 0.001 ) {
@@ -135,14 +144,16 @@ for (my $s = 0.50; $s < 0.90; $s += 0.001) {
}
}
}
-warn sprintf( 's%1.3f, l%1.3f -> %s',
+warn sprintf( 's%1.3f, l%1.3f â %s',
@$best );
-my $baseTheme = "AppTheme.NoActionBar";
+my $baseTheme = "AppTheme";
+
+use constant STEP_DEGREES => 5;
# # hsb
-# for( my $hue = 0; $hue < 360; $hue += 15 ) {
-# printf "\n";
+ $result .= sprintf "$indent- #%s
\n",
+ 'colorPrimary', hslHex( $hue, $S, $l1 );
+ $result .= sprintf "$indent- #00%s
\n",
+ 'colorPrimaryTransparent', hslHex( $hue, $S, $l1 );
+ $result .= sprintf "$indent- #%s
\n",
+ 'colorAccent', hslHex( $hue, $S, $l2 );
+ $result .= sprintf "$indent- #%s
\n",
+ 'colorPrimaryDark', hslHex( $hue, $S, $l2 );
+ $result .= sprintf "$indent- #%s
\n",
+ 'table_row_dark_bg', hslHex( $hue, $S, $l3 );
+ $result .= sprintf "$indent- #%s
\n",
+ 'table_row_light_bg', hslHex( $hue, $S, $l4 );
+ $result .= "$baseIndent\n";
return $result;
}
@@ -220,17 +249,20 @@ if ($xml) {
my $start_marker = '';
my $end_marker = '';
my ($fh, $filename) = tempfile(basename($0).'.XXXXXXXX', DIR => dirname($xml));
+ $fh->binmode(':utf8');
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;