4
die "Usage: gen-color-table.pl rgb.txt > xpm-color-table.h\n";
7
open IN, $ARGV[0] || die "Cannot open $ARGV[0]: $!\n";
10
while (defined($_ = <IN>)) {
12
if (!/^\s*([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+(.*\S)\s+$/) {
13
die "Cannot parse line $_";
16
push @colors, [$1, $2, $3, $4];
19
@colors = sort { lc($a->[3]) cmp lc($b->[3]) } @colors;
26
/* xpm-color-table.h: Generated by gen-color-table.pl from rgb.txt
32
static const char color_names[] =
35
for $color (@colors) {
41
print qq( "$name\\0");
43
$color->[4] = $offset;
44
$offset += length($name) + 1;
57
static const XPMColorEntry xColors[] = {
61
for $color (@colors) {
65
$offset = $color->[4];
70
print " { $offset, $red, $green, $blue }";