Python Text Gradients

When developing Streaks, for no particular reason I decided to add colourful gradients to the text. This could symbolise progression, or just look cool.

I discovered an incredibly useful set of functions by Ben Southgate which does exactly that. After wrapping them in a simple Python class, and combining with the excellently featured but awfully named Rich, the output is much more pleasant than simple white crosses and dots.

Streaks with gradients

The gradients generated adapt to the length of the string, so even much longer text should look smooth:

Longer text with gradients

and with any hex colours:

Longer text with gradients

Since this gradient generation is applicable outside of this context, I’ve made it available on GitHub.