4 use Shiar_Sheet::Colour 1.05;
6 say "# automatically generated by $0";
12 for my $path (@ARGV) {
13 open my $theme, '<', $path or do {
14 warn "could not open $path: $!\n";
17 (my $name = $path) =~ s{.*/}{}; # basename
20 while (readline $theme) {
22 (?: (foreground | background) | color(\d+) ) \h* : \h*
23 (?: \#(\S+) | rgb:(\S+) )
25 my ($name, $idx, $val) = ($1, $2, uc $+);
26 $name or $idx < 16 or next;
27 $val =~ s/[^0-9A-F]//g;
28 ($name ? $pal{$name} : $pal[$idx]) = $val;
34 grep { ($_->hsv)[1] > 32 } # ignore unsaturated
35 map { Shiar_Sheet::Colour->new($_) }
39 $huesum += abs($lasthue - $hue) > .02 if defined $lasthue;
42 $huesum > 3 or next; # require number of significant hue changes
43 #TODO tweak to include good-pants, exclude cheesecake-*
45 if ($seen{"@pal"}++) {
46 warn "ignore duplicate palette $name\n";
50 splice @pal, 8 if "@pal[0..7]" eq "@pal[8..15]";
53 say qq(\ttitle => '$name',);
54 say qq(\tparent => 'cga',);
55 say qq(\tlist => [qw(@pal)],);
56 say qq(\t$_ => '$pal{$_}',) for keys %pal;
61 say 'xcolor => [', join(', ', map {"'$_'"} @names), '],';