Created
April 17, 2012 07:32
-
-
Save tomoe-mami/2404198 to your computer and use it in GitHub Desktop.
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
-- Displays xterm 256 color palette | |
bright_fg, dark_fg = 47, 40 | |
function print_section_title(text) | |
local width = 42 | |
local title = " " .. text .. " " | |
local tile = "\226\148\129" | |
print( "\027[7m" .. title .. "\027[m" .. string.rep(tile, (width - #title)) ) | |
end | |
print_section_title("SYSTEM") | |
for color = 0, 15 do | |
if (color % 6) == 0 then io.stdout:write("\n") end | |
io.stdout:write(string.format( | |
"\027[38;5;%u;7m\027[%um %03u \027[m", | |
color, | |
((color == 0 or color == 4) and bright_fg or dark_fg), | |
color)) | |
end | |
print("\n") | |
print_section_title("CUBE") | |
print("") | |
for red = 0, 5 do | |
for green = 0, 5 do | |
for blue = 0, 5 do | |
color = 16 + (red * 36) + (green * 6) + blue | |
io.stdout:write(string.format( | |
"\027[38;5;%u;7m\027[%um %03u \027[m", | |
color, | |
(green == 0 and bright_fg or dark_fg), | |
color)) | |
end | |
print("") | |
end | |
end | |
print("") | |
print_section_title("GRAYSCALE") | |
i = 0 | |
for color = 232, 255 do | |
if i == 0 then print("") end | |
io.stdout:write(string.format( | |
"\027[38;5;%u;7m\027[%um %03u \027[m", | |
color, | |
(color < 238 and bright_fg or dark_fg), | |
color)) | |
i = (i + 1) % 6 | |
end | |
print("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment