Created
June 25, 2021 11:44
-
-
Save Refffy/441c49a2a83877a41e272ea8bb6aa9ba to your computer and use it in GitHub Desktop.
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
from random import sample, randint | |
from colr import color | |
# From itertools recipes | |
def random_permutation(iterable, r=None): | |
pool = tuple(iterable) | |
r = len(pool) if r is None else r | |
yield tuple(sample(pool, r)) | |
def hex_color_perm(): | |
colors = random_permutation(range(0x00, 0xff), 3) | |
for color in colors: | |
yield '#' + ''.join( | |
hex(i) for i in color | |
).replace('0x', '') | |
yield color | |
def hex_color(): | |
color = "#" | |
for _ in range(3): | |
color += hex(randint(0x00, 0xff)).replace('0x', '') | |
return color | |
if __name__ == '__main__': | |
string = hex_color_perm() | |
values = next(string), next(string) | |
clr = hex_color() | |
print( | |
color( | |
f''' | |
HTML-color:{values[0]} | |
RGB value:{values[1]} | |
''', fore=values[1] | |
), | |
clr | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment