Last active
December 18, 2015 22:29
-
-
Save glucero/5855300 to your computer and use it in GitHub Desktop.
terminal colormap
This file contains hidden or 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 ruby | |
def color_map | |
yield ->(offset) { ->(color) { print "\x1b[48;5;#{color + offset}m " } } | |
print "\x1b[0m", ?\n | |
end | |
puts 'System colors:' | |
color_map { |color| 8.times &color[0] } | |
color_map { |color| 8.times &color[8] } | |
puts ?\n, 'Color map:' | |
6.times do |green| | |
color_map do |color| | |
6.times do |red| | |
6.times &color[16 + (red * 36) + (green * 6)] # blue | |
end | |
end | |
end | |
puts ?\n, 'Grayscale map:' | |
color_map { |color| 24.times &color[232] } |
Author
glucero
commented
Jun 25, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment