Created
May 31, 2014 12:31
-
-
Save babarot/4a38d74693087a1ed4b6 to your computer and use it in GitHub Desktop.
Shows 256 colors can be displayed on the console
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 $fg = "\x1b[38;5;"; | |
my $bg = "\x1b[48;5;"; | |
my $rs = "\x1b[0m"; | |
my $color = 0; | |
for (my $row = 0; $row < 32; ++$row) { | |
for (my $col = 0; $col < 8; ++$col) { | |
print get_color($color); | |
$color++; | |
} | |
print "\n"; | |
} | |
sub get_color { | |
my ($color) = @_; | |
my $number = sprintf '%3d', $color; | |
return qq/${bg}${color}m ${number} ${rs} ${fg}${color}m${number}${rs} /; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment