Created
January 23, 2014 01:54
-
-
Save hatyuki/8571393 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
my $count = 0; | |
my $fg = "\x1b[38;5;"; | |
my $bg = "\x1b[48;5;"; | |
my $rs = "\x1b[0m"; | |
sub swatch | |
{ | |
my $color = shift; | |
my $number = sprintf '%3d', $color; | |
return "${bg}${color}m ${number} ${rs} ${fg}${color}m${number}${rs} "; | |
} | |
# display the colors | |
# first the system ones: | |
print "System colors:\n"; | |
for my $color (0..15) { | |
print swatch($color); | |
print "\n" unless ++$count % 8; | |
} | |
print "\n"; | |
# now the color cube | |
$count = 0; | |
print "Color cube, 6x6x6:\n"; | |
for my $color (16..231) { | |
print swatch($color); | |
print "\n" unless ++$count % 6; | |
print "\n" unless $count % 36; | |
} | |
# now the grayscale ramp | |
$count = 0; | |
print "Grayscale ramp:\n"; | |
for my $color (232..255) { | |
print swatch($color); | |
print "\n" unless ++$count % 12; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment