Last active
December 31, 2019 14:08
-
-
Save cmdneo/57421dba388297797cfb8d5366e34d69 to your computer and use it in GitHub Desktop.
Prints a bunch of random 24-bit colors(3 char width) to the terminal using ansi escsape codes.
This file contains 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
r"""Prints random 24-bit colors(3 char width) | |
to the terminal using ansi escsape codes. | |
Use like: | |
python ansi-cols.py NO_OF_COLORED_CELLS | |
Example: | |
python ansi-cols.py 69_420 | |
""" | |
import sys | |
import random | |
limit = 0 | |
try: | |
limit = int(sys.argv[1]) | |
except (IndexError, ValueError): | |
print("Give number of cells to print, like: python ansi-cols.py 69420") | |
sys.exit(1) | |
for _x in range(limit): | |
cols = [random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)] | |
print(f"\033[48;2;{cols[0]};{cols[1]};{cols[2]}m \033[0m", end="") | |
print("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment