Skip to content

Instantly share code, notes, and snippets.

@sunsunza2009 sunsunza2009/HNY.py

Created Dec 31, 2016
Embed
What would you like to do?
Happy new year from ASCIImatics
from asciimatics.effects import Stars, Print,Cycle
from asciimatics.particles import RingFirework, SerpentFirework, StarFirework, PalmFirework
from asciimatics.renderers import SpeechBubble, FigletText, Rainbow
from asciimatics.scene import Scene
from asciimatics.screen import Screen
from asciimatics.exceptions import ResizeScreenError
from random import randint, shuffle, choice
import sys
def demo(screen):
colorList = [1, 2, 3, 4, 5, 6, 7]
shuffle(colorList)
scenes = []
effects = [
Print(screen,
FigletText("10", font='big'),
y=screen.height //2,
colour=colorList[0],
clear=True,
start_frame=0,
stop_frame=25),
Print(screen,
FigletText("9", font='big'),
y=screen.height //2,
colour=colorList[1],
clear=True,
start_frame=25,
stop_frame=50),
Print(screen,
FigletText("8", font='big'),
y=screen.height //2,
colour=colorList[2],
clear=True,
start_frame=50,
stop_frame=75),
Print(screen,
FigletText("7", font='big'),
y=screen.height //2,
colour=colorList[randint(0, 6)],
clear=True,
start_frame=75,
stop_frame=100),
Print(screen,
FigletText("6", font='big'),
y=screen.height //2,
colour=colorList[3],
clear=True,
start_frame=100,
stop_frame=125),
Print(screen,
FigletText("5", font='big'),
y=screen.height //2,
colour=colorList[4],
clear=True,
start_frame=125,
stop_frame=150),
Print(screen,
FigletText("4", font='big'),
y=screen.height //2,
colour=colorList[5],
clear=True,
start_frame=150,
stop_frame=175),
Print(screen,
FigletText("3", font='big'),
y=screen.height //2,
colour=colorList[randint(0, 6)],
clear=True,
start_frame=175,
stop_frame=200),
Print(screen,
FigletText("2", font='big'),
y=screen.height //2,
colour=colorList[6],
clear=True,
start_frame=200,
stop_frame=225),
Print(screen,
FigletText("1", font='big'),
y=screen.height //2,
colour=colorList[randint(0, 6)],
clear=True,
start_frame=225,
stop_frame=250),
Stars(screen, screen.width,start_frame=250),
Print(screen,
SpeechBubble("Press space to see it again"),
y=screen.height - 3,
start_frame=450)
]
for _ in range(20):
fireworks = [
(PalmFirework, 25, 30),
(PalmFirework, 25, 30),
(StarFirework, 25, 35),
(StarFirework, 25, 35),
(StarFirework, 25, 35),
(RingFirework, 20, 30),
(SerpentFirework, 30, 35),
]
firework, start, stop = choice(fireworks)
effects.insert(
1,
firework(screen,
randint(0, screen.width),
randint(screen.height // 8, screen.height * 3 // 4),
randint(start, stop),
start_frame=250),
)
effects.append(Cycle(
screen,
FigletText("HAPPY", font='big'),
int(screen.height / 2 - 6),
start_frame=350),)
effects.append(Cycle(
screen,
FigletText("NEW YEAR!", font='big'),
int(screen.height / 2 + 1),
start_frame=375),)
effects.append(Print(
screen,
FigletText("From ZuGeTor iT", font='small'),
int(screen.height / 2 + 10),
start_frame=375),)
scenes.append(Scene(effects, -1))
screen.play(scenes, stop_on_resize=True)
while True:
try:
Screen.wrapper(demo)
sys.exit(0)
except ResizeScreenError:
pass
except KeyboardInterrupt:
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.