Skip to content

Instantly share code, notes, and snippets.

@iwill
Forked from justinabrahms/colortest.py
Created October 12, 2022 14:28
Show Gist options
  • Save iwill/c7b32de9a96ce1b07c6074100ee4246b to your computer and use it in GitHub Desktop.
Save iwill/c7b32de9a96ce1b07c6074100ee4246b to your computer and use it in GitHub Desktop.

Revisions

  1. @justinabrahms justinabrahms revised this gist Jun 26, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion colortest.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@

    #!/usr/bin/env python
    # Ported to Python from http://www.vim.org/scripts/script.php?script_id=1349

    print "Color indexes should be drawn in bold text of the same color."
  2. Stan Klimoff revised this gist Apr 15, 2011. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions colortest.py
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@

    # Ported to Python from http://www.vim.org/scripts/script.php?script_id=1349

    print "Color indexes should be drawn in bold text of the same color."
    print

    colored = [0] + [0x5f + 40 * n for n in range(0, 5)]
    colored_palette = [
    @@ -21,5 +23,7 @@
    reset = "\033[0m"

    for (i, color) in enumerate(colored_palette + grayscale_palette, 16):
    print (bold + "%4s" + reset) % (i, str(i) + ':'), (normal + "%s" + reset) % (i, color),
    if(i % 6 == 3): print
    index = (bold + "%4s" + reset) % (i, str(i) + ':')
    hex = (normal + "%s" + reset) % (i, color)
    newline = '\n' if i % 6 == 3 else ''
    print index, hex, newline,
  3. Stan Klimoff revised this gist Apr 15, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions colortest.py
    Original file line number Diff line number Diff line change
    @@ -21,5 +21,5 @@
    reset = "\033[0m"

    for (i, color) in enumerate(colored_palette + grayscale_palette, 16):
    print (bold + "%4s" + reset) % (i, str(i) + ':'), (normal + "%s" + reset) % (i, color),
    if(i % 6 == 3): print
    print (bold + "%4s" + reset) % (i, str(i) + ':'), (normal + "%s" + reset) % (i, color),
    if(i % 6 == 3): print
  4. Stan Klimoff created this gist Apr 15, 2011.
    25 changes: 25 additions & 0 deletions colortest.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    # Ported to Python from http://www.vim.org/scripts/script.php?script_id=1349

    print "Color indexes should be drawn in bold text of the same color."

    colored = [0] + [0x5f + 40 * n for n in range(0, 5)]
    colored_palette = [
    "%02x/%02x/%02x" % (r, g, b)
    for r in colored
    for g in colored
    for b in colored
    ]

    grayscale = [0x08 + 10 * n for n in range(0, 24)]
    grayscale_palette = [
    "%02x/%02x/%02x" % (a, a, a)
    for a in grayscale
    ]

    normal = "\033[38;5;%sm"
    bold = "\033[1;38;5;%sm"
    reset = "\033[0m"

    for (i, color) in enumerate(colored_palette + grayscale_palette, 16):
    print (bold + "%4s" + reset) % (i, str(i) + ':'), (normal + "%s" + reset) % (i, color),
    if(i % 6 == 3): print