An utility to create and print gradients in Python
- Compact
- Dynamic (adapts to text size)
- Supports RGB!
To create a gradient, use the gradient and pass as argumets two rgb colors.
from gradient import Color, gradient
text = """
████████╗███████╗██╗ ██╗████████╗
╚══██╔══╝██╔════╝╚██╗██╔╝╚══██╔══╝
██║ █████╗ ╚███╔╝ ██║
██║ ██╔══╝ ██╔██╗ ██║
██║ ███████╗██╔╝ ██╗ ██║
╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝
"""
print(gradient(Color(112, 11, 250), Color(40, 221, 242), text))
Doing animated gradients is a little more complicated. To use them, you will need to have a loop and create an Animation instance, which takes two colors, the text, the animation duration and a step:
from gradient import animated_gradient, Color, Animation
text = """
████████╗███████╗██╗ ██╗████████╗
╚══██╔══╝██╔════╝╚██╗██╔╝╚══██╔══╝
██║ █████╗ ╚███╔╝ ██║
██║ ██╔══╝ ██╔██╗ ██║
██║ ███████╗██╔╝ ██╗ ██║
╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝
"""
animation = Animation(Color(40, 221, 242), Color(112, 11, 250), text, 5, .5)
while True:
print(animated_gradient(animation))
#Other actions
animation.tick()
- Add vertical and if i have the required IQ diagonal.
- Support more than 2 colors.