ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/gencolorlevel
Revision: 1.1
Committed: Tue May 11 18:46:50 2021 UTC (3 years ago) by sf-exg
Branch: MAIN
Log Message:
Improve 24-bit direct color accuracy

Patch by Fengguang Wu.

File Contents

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