#!/usr/bin/perl -w use strict; sub generate_palette() { my @palette = ( [ 0, 0, 0], [0x80, 0, 0], [ 0, 0x80, 0], [0x80, 0x80, 0], [ 0, 0, 0x80], [0x80, 0, 0x80], [ 0, 0x80, 0x80], [0xc0, 0xc0, 0xc0], [0x80, 0x80, 0x80], [0xff, 0, 0], [ 0, 0xff, 0], [0xff, 0xff, 0], [ 0, 0, 0xff], [0xff, 0, 0xff], [ 0, 0xff, 0xff], [0xff, 0xff, 0xff], ); my @x = (0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff); for(my $r = 0; $r < 6; $r++) { for(my $g = 0; $g < 6; $g++) { for(my $b = 0; $b < 6; $b++) { push @palette, [$x[$r], $x[$g], $x[$b]]; } } } my @gray = (0x08, 0x12, 0x1c, 0x26, 0x30, 0x3a, 0x44, 0x4e, 0x58, 0x62, 0x6c, 0x76, 0x80, 0x8a, 0x94, 0x9e, 0xa8, 0xb2, 0xbc, 0xc6, 0xd0, 0xda, 0xe4, 0xee); foreach my $i (@gray) { push @palette, [$i, $i, $i]; } return @palette; } my @palette = generate_palette(); for(my $i = 0; $i < 256; $i++) { printf "%3d %02x %02x %02x \e[48;5;%dm \e[0m\n", $i, $palette[$i][0], $palette[$i][1], $palette[$i][2], $i; }