summaryrefslogtreecommitdiff
path: root/xterm256lut_gen.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-11-19 14:24:04 +0100
committerjaseg <git@jaseg.de>2022-11-19 14:24:04 +0100
commit8ed4ce20a56123e0dfb0b0e1039c9a733fec3b5f (patch)
tree335f1ff7ace350cc66f1ab89acc661b68011fde8 /xterm256lut_gen.py
parent6db5a0fa5005710ff1a71a721b3d625e61c37e78 (diff)
downloadlolcat-8ed4ce20a56123e0dfb0b0e1039c9a733fec3b5f.tar.gz
lolcat-8ed4ce20a56123e0dfb0b0e1039c9a733fec3b5f.tar.bz2
lolcat-8ed4ce20a56123e0dfb0b0e1039c9a733fec3b5f.zip
Add --gradient option, allow specification of custom gradients.
Closes #47
Diffstat (limited to 'xterm256lut_gen.py')
-rw-r--r--xterm256lut_gen.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/xterm256lut_gen.py b/xterm256lut_gen.py
new file mode 100644
index 0000000..16d8f4b
--- /dev/null
+++ b/xterm256lut_gen.py
@@ -0,0 +1,24 @@
+
+xterm_colors = []
+
+# This is ripped out of pygments
+# I leave out the 16 standard colors since people tend to re-define them to their liking.
+
+# colors 16..232: the 6x6x6 color cube
+_valuerange = (0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff)
+for i in range(217):
+ r = _valuerange[(i // 36) % 6]
+ g = _valuerange[(i // 6) % 6]
+ b = _valuerange[i % 6]
+ xterm_colors.append((r, g, b))
+
+# colors 233..253: grayscale
+for i in range(1, 24):
+ v = 8 + i * 10
+ xterm_colors.append((v, v, v))
+
+print('/* GENERATED HEADER FILE DO NOT EDIT */')
+print('union rgb_c xterm256lut[256-16] = {')
+for r,g,b in xterm_colors:
+ print(f' {{{{0x{b:02x}, 0x{g:02x}, 0x{r:02x}}}}},');
+print('};');