MaxGradient
PyPI - MaxGradient PyPI - MaxGradient Version 0.2.12
MaxGradient

MaxGradient automates printing gradient colored text to the console. It's built upon the great rich library. It contains a Console that can serve as a drop in replacement for rich.console.Console and has an expanded Color class which can parse X11 color names on top of rich's standard colors. MaxGradient is a work in progress and I'm open to any suggestions or contributions.

Installation

MaxGradient can be installed from PyPi using your favorite python package manager:

PDM (Recommended)

pdm add maxgradient

PIP

pip install maxgradient

Usage

Quick Start

The basic usage is to create a console object and use it to print gradient text. MaxGradient.Console is a drop in replacement for rich.rich.Console and can be used in the same way. It does, however, have some additional methods like gradient().

Example

#import console from MaxGradient
import maxgradient as mg

console = mg.Console() # Initialize a console
console.gradient(
    "Hello, World!",
    justify = "center"
)
Hello, World!

Gradient with Color

MaxGradient easily make random gradients that require no more than the text you wish to color, it can also be used to make gradients with specific colors. The gradient() method takes a string of text as well as a list of colors. The number of colors in the list determines the number of colors in the gradient. The gradient will be evenly distributed between the colors in the list. The gradient will be applied to the text in the order it is given in the list.

MaxGradient accepts the following as

  • color names (red, orange, yellow, green, cyan, lightblue, blue, purple, violet, magenta)
  • hex color codes (3-digit -> #f0f, 6-digit -> #ff00ff)
  • rgb color codes
  • X11 named colors
  • as well as any colors from rich's standard library.

Let's take a look at some examples:

Example 1
import maxgradient as mg

console = mg.Console() # Initialize a console
console.gradient(
    "This gradient contains the colors: magenta, violet, and purple.",
    colors = [
        "magenta",
        "violet",
        "purple"
    ])
Gradient with Color 1


Example 2

You are not just stuck with ROY G BIV colors, you can use any colors you want. Let's make a gradient with the colors: magenta, violet, purple, blue, lightblue, and cyan.
console.gradient(
    "This gradient contains the colors: magenta, violet, purple, blue, lightblue, and cyan.",
    colors = [
        "rgb(255,0,255)", # rgb | magenta
        "violet", # named
        "#5f00ff", # hex | purple
        "blue", # another named
        "rgb(0, 136, 255)", # rgb | lightblue
        "cyan" # and another
    ]
)

Gradient with Color 2
Created by
Max Ludden's Logo
Max Ludden