Add color selection and printing functions with documentation
This commit is contained in:
parent
27d01aeb0f
commit
d313c78b5b
@ -1,40 +1,14 @@
|
|||||||
|
|
||||||
def print_green(*args):
|
|
||||||
text = ""
|
|
||||||
for arg in args:
|
|
||||||
text += str(arg) + " "
|
|
||||||
print(f"\033[92m{text}\033[0m")
|
|
||||||
|
|
||||||
|
|
||||||
def print_red(*args):
|
|
||||||
text = ""
|
|
||||||
for arg in args:
|
|
||||||
text += str(arg) + " "
|
|
||||||
print(f"\033[91m{text}\033[0m")
|
|
||||||
|
|
||||||
|
|
||||||
def print_yellow(*args):
|
|
||||||
text = ""
|
|
||||||
for arg in args:
|
|
||||||
text += str(arg) + " "
|
|
||||||
print(f"\033[93m{text}\033[0m")
|
|
||||||
|
|
||||||
|
|
||||||
def print_blue(*args):
|
|
||||||
text = ""
|
|
||||||
for arg in args:
|
|
||||||
text += str(arg) + " "
|
|
||||||
print(f"\033[94m{text}\033[0m")
|
|
||||||
|
|
||||||
|
|
||||||
def print_purple(*args):
|
|
||||||
text = ""
|
|
||||||
for arg in args:
|
|
||||||
text += str(arg) + " "
|
|
||||||
print(f"\033[95m{text}\033[0m")
|
|
||||||
|
|
||||||
|
|
||||||
def choose_color(last_color_index):
|
def choose_color(last_color_index):
|
||||||
|
"""
|
||||||
|
Selects the next color in a predefined sequence of colors.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
last_color_index (int): The index of the last color used.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
tuple: A tuple containing the ANSI escape code for the selected color (str)
|
||||||
|
and the index of the selected color (int).
|
||||||
|
"""
|
||||||
colors = {
|
colors = {
|
||||||
"blue": "\033[94m",
|
"blue": "\033[94m",
|
||||||
"green": "\033[92m",
|
"green": "\033[92m",
|
||||||
@ -47,7 +21,70 @@ def choose_color(last_color_index):
|
|||||||
color = color_keys[color_index]
|
color = color_keys[color_index]
|
||||||
return colors[color], color_index
|
return colors[color], color_index
|
||||||
|
|
||||||
|
|
||||||
|
def print_green(*args):
|
||||||
|
"""
|
||||||
|
Prints the provided arguments in green.
|
||||||
|
"""
|
||||||
|
text = ""
|
||||||
|
for arg in args:
|
||||||
|
text += str(arg) + " "
|
||||||
|
print(f"\033[92m{text}\033[0m")
|
||||||
|
|
||||||
|
|
||||||
|
def print_red(*args):
|
||||||
|
"""
|
||||||
|
Prints the provided arguments in red.
|
||||||
|
"""
|
||||||
|
text = ""
|
||||||
|
for arg in args:
|
||||||
|
text += str(arg) + " "
|
||||||
|
print(f"\033[91m{text}\033[0m")
|
||||||
|
|
||||||
|
|
||||||
|
def print_yellow(*args):
|
||||||
|
"""
|
||||||
|
Prints the provided arguments in yellow.
|
||||||
|
"""
|
||||||
|
text = ""
|
||||||
|
for arg in args:
|
||||||
|
text += str(arg) + " "
|
||||||
|
print(f"\033[93m{text}\033[0m")
|
||||||
|
|
||||||
|
|
||||||
|
def print_blue(*args):
|
||||||
|
"""
|
||||||
|
Prints the provided arguments in blue.
|
||||||
|
"""
|
||||||
|
text = ""
|
||||||
|
for arg in args:
|
||||||
|
text += str(arg) + " "
|
||||||
|
print(f"\033[94m{text}\033[0m")
|
||||||
|
|
||||||
|
|
||||||
|
def print_purple(*args):
|
||||||
|
"""
|
||||||
|
Prints the provided arguments in purple.
|
||||||
|
"""
|
||||||
|
text = ""
|
||||||
|
for arg in args:
|
||||||
|
text += str(arg) + " "
|
||||||
|
print(f"\033[95m{text}\033[0m")
|
||||||
|
|
||||||
|
|
||||||
def print_rainbow(*args):
|
def print_rainbow(*args):
|
||||||
|
"""
|
||||||
|
Prints the provided arguments in a rainbow of colors.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
*args: Variable length argument list. Each argument can be a string, list, or dictionary.
|
||||||
|
- If the argument is a list, each element in the list will be printed in a different color.
|
||||||
|
- If the argument is a dictionary, each key-value pair will be printed in a different color.
|
||||||
|
- If the argument is a string or any other type, it will be printed in a different color.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
"""
|
||||||
color_index = -1
|
color_index = -1
|
||||||
text = ""
|
text = ""
|
||||||
for arg in args:
|
for arg in args:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user