Skip to content

Instantly share code, notes, and snippets.

@pen
Created May 23, 2017 03:14
Show Gist options
  • Save pen/0b6a3c15524b17f34a808a1852b86862 to your computer and use it in GitHub Desktop.
Save pen/0b6a3c15524b17f34a808a1852b86862 to your computer and use it in GitHub Desktop.
xterm-256colorsの色を表示
#!/usr/bin/perl
use strict;
use warnings;
# ESC [ 38 ; 5 ; %3d m ForeGround
# ESC [ 48 ; 5 ; %3d m BackGround
my @formats = ( "\e[48;5;%dm \e[m ", "%3d " );
print "System colors:\n";
for my $bright (0..1) {
for my $format (@formats) {
for my $code (0..7) {
my $color = $bright * 8 + $code;
printf($format, $color);
}
print "\n";
}
}
print "\n";
print "Color cube, 6x6x6:\n";
for my $red_base (0..1) {
for my $green (0..5) {
for my $format (@formats) {
for my $red (0..2) {
for my $blue (0..5) {
my $color = ((($red_base * 3) + $red) * 6 + $green) * 6 + $blue + 16;
printf($format, $color);
}
print " ";
}
print "\n";
}
}
print "\n";
}
print "Grayscale ramp:\n";
for my $scale_base (0..1) {
for my $format (@formats) {
for my $scale (0..11) {
my $color = $scale_base * 12 + $scale + 232;
printf($format, $color);
}
print "\n";
}
}
print "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment