From efe3348d05651915b9059482fcd6dfca0e5a0cea Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Sat, 20 Jun 2020 16:49:34 +0200 Subject: [PATCH] 4bit and 8bit implemented --- terminalcolors.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 terminalcolors.py diff --git a/terminalcolors.py b/terminalcolors.py new file mode 100755 index 0000000..c4ffeae --- /dev/null +++ b/terminalcolors.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +default = "\033[0m" +bar = " " +def colors4(): + print("4 Bit colors:") + seq_template = "\033[{};{}m{}" + for color in range(40, 48): + print(seq_template.format(30, color, color) + bar + default) + +def colors8(): + print("8 bit colors:") + seq_template = "\033[{};{};{}m{}" + for color in range(16, 255): + if color < 100: + seq_template = "\033[{};{};{}m {}" + else: + seq_template = "\033[{};{};{}m{}" +# colorstring = "".join(seq_template.format(48, 5, i, i) for i in range(color, color + 36 )) + print(seq_template.format(48, 5, color, color), end='') + if color % 36 == 15: + print() + #print(seq_template.format(48, 5, color) + bar + default) +def main(): + colors4() + colors8() + +if __name__ == "__main__": + main()