Skip to content
Sign upLog in
← Back to Community

β¬œβ¬› Color Fading Animation 🎬πŸŽ₯

Profile icon
[deleted]

β¬œβ¬› Color Fading Animation 🎬πŸŽ₯

Hope everyone is doing well >:)

In this tutorial, I will teach you how to do a color fading animation. It's very simple.

Import

You need to import these modules:

import os # for clearing the screen from time import sleep # for waiting

That's all the modules!

Colors

We don't need to import colors because we could just defined some colors:

black = "\033[0;30m" white = "\033[0;37m" gray = "\x1b[90m" bright_white = "\033[0;97m"

These colors because they go well with each other in the fading animation.

Actual Code

First we need to print the brightest, darker, more darker, darkest. In this case:

print(f"{bright_white}Hello World") print(f"{white}Hello World") print(f"{gray}Hello World") print(f"{black}Hello World")

This is a mistake

because there is waiting in between so each frame looks terrible. And we didn't clear the screen every time so it just printed it all out at once.

FIRST, we need to define the clear screen. (it's up to you if you want to do it, if you don't want to define it, just do:)

os.system("clear")

If you want to defined it, just do:

def clear(): os.system("clear")

Then, you need to sleep in between each frame. I recommend sleeping 0.05 seconds. But...it's up to you.

FINALLY: finaly code:

print(f"{bright_white}Hello World") sleep(0.05) os.system("clear") print(f"{white}Hello World") sleep(0.05) os.system("clear") print(f"{gray}Hello World") sleep(0.05) os.system("clear") print(f"{black}Hello World")

If you liked this tutorial, slamπŸ”¨ that upvote button and make sure to check out my other tutorials too:

Python- The Basics Tutorial: https://repl.it/talk/learn/Python-The-Basics/117133

Getkey Function tutorial: https://repl.it/talk/learn/GetKey-Function-Tutorial/116955

Data Base Tutorial: https://repl.it/talk/learn/Python-Data-Base-Tutorial/117319

>That's it! πŸ‘‹

The project is down below πŸ‘‡. A PEACE! πŸ‘‹ πŸ‘‹ πŸ‘‹ πŸ‘‹

Voters
Profile icon
NathanFlynn3
Profile icon
TsunamiOrSmth
Profile icon
SilvermoonCat
Profile icon
LuckyOreos
Comments
hotnewtop
Profile icon
SilvermoonCat

cooooool
suggest you add a while loop so it goes on forever :D

Profile icon
FourtyCoder

while True:
#code


@SilvermoonCat

Profile icon
LuckyOreos

Coooool