Skip to content

Commit

Permalink
better ascii art colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Symes committed Nov 8, 2023
1 parent 48032f8 commit 2b44cb0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion henon2midi/ascii_art.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class AsciiArtCanvas:
"bright_cyan": "\033[1;36m",
"bright_white": "\033[1;37m",
}
COLORS_LIST = list(COLORS.keys())
random.shuffle(COLORS_LIST)

def __init__(self, width: int = 120, height: int = 80):
self.width = width
Expand All @@ -37,6 +39,10 @@ def draw_point(self, x: int, y: int, character: str = "X"):
def set_color(self, color: str):
if color == "random":
color = random.choice(list(self.COLORS.keys()))
elif color == "next":
index_of_current_color = self.COLORS_LIST.index(self.current_color)
index_of_next_color = (index_of_current_color + 1) % len(self.COLORS_LIST)
color = self.COLORS_LIST[index_of_next_color]
elif color not in self.COLORS:
raise Exception(f"Color {color} not supported")

Expand Down Expand Up @@ -65,7 +71,7 @@ def draw_data_point_on_canvas(
if current_iteration == 1:
ascii_art_canvas.clear()
if is_new_orbit:
ascii_art_canvas.set_color("random")
ascii_art_canvas.set_color("next")
try:
x_canvas_coord = round(
rescale_number_to_range(
Expand Down

0 comments on commit 2b44cb0

Please sign in to comment.