52 lines
1.1 KiB
Lua
52 lines
1.1 KiB
Lua
local function xterm256_palette()
|
||
local colors = {}
|
||
|
||
-- 0–15: system colors (manual)
|
||
local ansi = {
|
||
"#000000", -- 0 black
|
||
"#d70000", -- 1 red
|
||
"#5f8700", -- 2 green
|
||
"#af8700", -- 3 yellow/brown
|
||
"#005faf", -- 4 blue
|
||
"#5f5faf", -- 5 magenta/indigo
|
||
"#008787", -- 6 cyan
|
||
"#bcbcbc", -- 7 light gray
|
||
|
||
"#808080", -- 8 dark gray
|
||
"#ff5f5f", -- 9 bright red
|
||
"#87d75f", -- 10 bright green
|
||
"#ffd700", -- 11 bright yellow
|
||
"#5f87d7", -- 12 bright blue
|
||
"#8787ff", -- 13 bright magenta
|
||
"#5fd7d7", -- 14 bright cyan
|
||
"#ffffff", -- 15 white
|
||
}
|
||
for i, hex in ipairs(ansi) do
|
||
colors[i-1] = hex
|
||
end
|
||
|
||
-- 16–231: 6x6x6 cube
|
||
local steps = {0, 95, 135, 175, 215, 255}
|
||
local idx = 16
|
||
for r = 1,6 do
|
||
for g = 1,6 do
|
||
for b = 1,6 do
|
||
colors[idx] = string.format("#%02x%02x%02x", steps[r], steps[g], steps[b])
|
||
idx = idx + 1
|
||
end
|
||
end
|
||
end
|
||
|
||
-- 232–255: grayscale
|
||
for gray = 0,23 do
|
||
local level = 8 + gray * 10
|
||
colors[idx] = string.format("#%02x%02x%02x", level, level, level)
|
||
idx = idx + 1
|
||
end
|
||
|
||
return colors
|
||
end
|
||
|
||
return xterm256_palette()
|
||
|