Skip to main content

A library to make printing gradient color to the terminal a lot easier. Think `lolcat` but utilizing python's `rich` library so you can use it anywhere.

Project description

<style> html { font-family: "Century Gothic"; font-size: 25px; } body { color: #fff; background: #111; } table { margin-left: 20px } td { font-family: 'Century Gothic'; padding-left: 5px; } .pdm { font-size: 20px; background: linear-gradient(to right, #ff00ff, #5f00ff); display: inline-block; -webkit-background-clip: text; background-clip: text; color: transparent; text-decoration: none; } a:hover { color: #000; } a:visited { color: #f00; } a:active { color: #ff5900; } .result { width: 50%; margin: auto; display: block; } </style>

MaxGradient

MaxGradient

MaxGradient automating printing gradient colored text to the console. It's built upon the great rich library.

Installation


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

PDM (Recommended)


    pdm add maxgradient

Pip


pip install maxgradient

Usage

Basic Usage

The basic usage is to create a console object and use it to print gradient text:

    
    import maxgradient as mg

    console = mg.Console()
    console.gradient("Hello, World!")
    





Gradient

You may also instantiate a Gradient Object. The Gradient class is a subclass of the rich.text.Text class, and can be used in the same way. The Gradient class has a few extra arguments available though.

class Gradient(rich.rich.Text):
    """Text with gradient color / style."""
    def __init__ (
        ext: Optional[str | Text] = "",
        colors: Optional[List[Color | Tuple | str]] = None,
        rainbow: bool = False,
        invert: bool = False,
        hues: Optional[int] = None,
        color_sample: bool = False,
        style: StyleType = Style.null(),
        *,
        # The arguments below are used directly by Text
        # so I won't cover them here. If you have questions,
        # check out the rich documentation.
        justify: Optional[JustifyMethod] = None,
        overflow: Optional[OverflowMethod] = None,
        no_wrap: Optional[bool] = None,
        end: str = "\n",
        tab_size: Optional[int] = 8,
        spans: Optional[List[Span]] = None,) -> None:

The Gradient class can utilize the above arguments to get a plethora of different gradients.

MaxGradient





Color

The final main component of MaxGradient is expanding the rich.color.Color class. The MaxGradient .Color class can still parse and ustilize the rich.color.Color's standard colors but in addition to Hex and RGB colors, it can also parse RGB Tuples as well as X11 color names. I've also included the colors that MaxGradient uses to create random gradients from for convienince. The follow are the available named colors as well as there hex and rgb colors:

Example

    
import maxgradient as mg

console = mg.Console() console.print("[bold lime]This is a a vibrant green color!")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maxgradient-0.1.1.tar.gz (35.0 kB view hashes)

Uploaded Source

Built Distribution

maxgradient-0.1.1-py3-none-any.whl (39.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page