[+] Random flag continuation

This commit is contained in:
Azalea 2023-06-01 22:42:48 -07:00
parent 83ba569fde
commit c47d80ae1d

View file

@ -1,4 +1,5 @@
import math import math
import random
from time import sleep from time import sleep
from hyfetch import presets from hyfetch import presets
@ -34,14 +35,19 @@ def start_animation():
text_start_x = w // 2 - text_width // 2 text_start_x = w // 2 - text_width // 2
text_end_x = text_start_x + text_width text_end_x = text_start_x + text_width
for i in range(blocks): colors += PRESETS['rainbow'].colors
colors += PRESETS['rainbow'].colors colors += PRESETS['transgender'].colors
colors += PRESETS['transgender'].colors colors += PRESETS['nonbinary'].colors
colors += PRESETS['agender'].colors
last_idx = len(colors) - 1
preset_items = set(PRESETS.items())
black = RGB(0, 0, 0) black = RGB(0, 0, 0)
white = RGB(255, 255, 255) white = RGB(255, 255, 255)
def draw_frame(): def draw_frame():
nonlocal colors, last_idx
buf = "" buf = ""
# Loop over the height # Loop over the height
@ -60,14 +66,28 @@ def start_animation():
# If it's a switching point # If it's a switching point
if idx % block_width == 0 or x == text_start_x - border or x == text_end_x + border: if idx % block_width == 0 or x == text_start_x - border or x == text_end_x + border:
cidx = (idx // block_width) % len(colors)
# Print the color at the current frame # Print the color at the current frame
c = colors[(idx // block_width) % len(colors)] c = colors[cidx]
if y_text and text_start_x - border <= x < text_end_x + border: if y_text and text_start_x - border <= x < text_end_x + border:
# buf += c.set_light(0.3).to_ansi_rgb(foreground=False) # buf += c.set_light(0.3).to_ansi_rgb(foreground=False)
buf += c.overlay(black, 0.5).to_ansi_rgb(foreground=False) buf += c.overlay(black, 0.5).to_ansi_rgb(foreground=False)
else: else:
buf += c.to_ansi_rgb(foreground=False) buf += c.to_ansi_rgb(foreground=False)
# If it's the last color of the last line, check if it's time to randomize new colors
if y == h - 1 and x > w - speed - 1:
# If idx = last_idx, it's time to randomize
if cidx == last_idx:
print("Hit")
input()
# Randomize colors
new = random.choice(list(preset_items))[1].colors
for c in new:
colors[last_idx] = c
last_idx = (last_idx + 1) % len(colors)
# If text should be printed, print text # If text should be printed, print text
if y_text and text_start_x <= x < text_end_x: if y_text and text_start_x <= x < text_end_x:
# Add white background # Add white background
@ -85,7 +105,7 @@ def start_animation():
while 1: while 1:
# Clear the screen # Clear the screen
print("\033[2J\033[H", end="") # print("\033[2J\033[H", end="")
draw_frame() draw_frame()
frame += speed frame += speed
sleep(frame_delay) sleep(frame_delay)