ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/gencolorlevel
Revision: 1.2
Committed: Thu May 13 19:24:28 2021 UTC (3 years ago) by root
Branch: MAIN
CVS Tags: rxvt-unicode-rel-9_26, rxvt-unicode-rel-9_25, rxvt-unicode-rel-9_30, rxvt-unicode-rel-9_29, HEAD
Changes since 1.1: +2 -0 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/usr/bin/perl
2
3 # generated the color_level table used when finding a nearby color in src/command.C
4
5 use strict;
6
7 my @coeffs =
8 # (4, 5, 6, 7);
9 # (0.36, 0.6, 0.9, 1.3);
10 # (0.4, 0.7, 1.0, 1.4);
11 (0.48, 0.77, 1.1, 1.5);
12
13 my @rows1;
14 my @rows2;
15 for my $coeff (@coeffs) {
16 my @row1;
17 my %occ;
18 for (0 .. 31) {
19 my $i = int sqrt $_ * $coeff;
20 push @row1, $i;
21 $occ{$i}++;
22 }
23
24 my @row2;
25 for my $i (sort keys %occ) {
26 my $n = $occ{$i};
27 my @values = ($i) x $n;
28 for my $j (1 .. ($n + 1) / 3) {
29 $values[$j - 1] = $i - 1 if $i > 0;
30 $values[-$j] = $i + 1 if $i < $row1[-1];
31 }
32 push @row2, @values;
33 }
34
35 push @rows1, \@row1;
36 push @rows2, \@row2;
37 }
38
39 print "static const unsigned char color_level[8][32] = {\n";
40 print " {" . join(", ", @$_) . "},\n" for @rows2;
41 print " {" . join(", ", @$_) . "},\n" for @rows1;
42 print "}\n";