Merry Christmas

 

import os
import time
from colorama import Fore, Style, init

# Initialize colorama
init(autoreset=True)

# Function to clear the screen
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')

# Function to generate a compact Christmas tree with animation
def generate_christmas_tree(levels, animate=True):
tree = []
# Add the star at the top
tree.append(Fore.YELLOW + " " * (levels - 1) + "⭐")
if animate:
display_tree(tree)
time.sleep(0.5)
# Decorations for the tree
decorations = [Fore.RED + "🎁", Fore.CYAN + "❄", Fore.MAGENTA + "🎀", Fore.WHITE + "✨"]
# Manually construct each row of the tree
if levels >= 1:
tree.append(" " * (levels - 1) + Fore.GREEN + "🎄")
if animate:
display_tree(tree)
time.sleep(0.5)

if levels >= 2:
tree.append(" " * (levels - 2) + Fore.GREEN + "🎄🎄")
if animate:
display_tree(tree)
time.sleep(0.5)

if levels >= 3:
tree.append(" " * (levels - 3) + Fore.GREEN + "🎄" + Fore.CYAN + "🎄" + Fore.GREEN + "🎄")
if animate:
display_tree(tree)
time.sleep(0.5)

if levels >= 4:
tree.append(" " * (levels - 4) + Fore.GREEN + "🎄" + Fore.MAGENTA + "🎄" + Fore.GREEN + "🎄" + Fore.GREEN + "🎄")
if animate:
display_tree(tree)
time.sleep(0.5)

if levels >= 5:
tree.append(" " * (levels - 5) + Fore.GREEN + "🎄" + Fore.RED + "🎄🎄" + Fore.CYAN + "🎄" + Fore.GREEN + "🎄")
if animate:
display_tree(tree)
time.sleep(0.5)

if levels >= 6:
tree.append(" " * (levels - 6) + Fore.GREEN + "🎄" + Fore.MAGENTA + "🎀" + Fore.WHITE + "✨" + Fore.GREEN + "🎄" + Fore.GREEN + "🎄" + Fore.GREEN + "🎄")
if animate:
display_tree(tree)
time.sleep(0.5)

# Add the trunk and base
trunk = Fore.YELLOW + " " * (levels - 1) + "||\n" + " " * (levels - 1) + "||"
base = Fore.RED + " " * (levels - 5) + "🎁🎁🎁🎁🎁"
tree += [trunk, base]

return tree

# Function to display the tree with optional text
def display_tree(tree, text="", color=Fore.CYAN):
clear_screen()
print("\n".join(tree))
if text:
print("\n" + color + Style.BRIGHT + text.center(50))

# Function to animate text below the tree
def animated_text(tree, text, color=Fore.CYAN, delay=0.1):
for i in range(len(text) + 1):
display_tree(tree, text[:i], color)
time.sleep(delay)

# Function for blinking "Merry Christmas" text
def blinking_text(tree, text, color1=Fore.RED, color2=Fore.GREEN, delay=0.5, blinks=6):
for _ in range(blinks):
display_tree(tree, text, color1)
time.sleep(delay)
display_tree(tree, text, color2)
time.sleep(delay)

# Main function for the animation
def christmas_tree_animation():
levels = 10 # Number of levels in the tree
tree = generate_christmas_tree(levels)

# Display animated text
animated_text(tree, "Wishing you a joyful holiday season!", color=Fore.YELLOW, delay=0.1)
animated_text(tree, "May your Christmas be filled with love and laughter!", color=Fore.MAGENTA, delay=0.1)

# Blinking "Merry Christmas" message
blinking_text(tree, "🎄 Merry Christmas! 🎄", Fore.RED, Fore.GREEN, delay=0.5)

if __name__ == "__main__":
christmas_tree_animation()

star = "\n\n\n\n"
print(star)
print(star)
print(star)
print(star)
print(star)

Comments

Popular Posts