Skip to main content

A module to genereate gradient text and rich panels.

Project description

maxcolor

Updated to 1.0.2

Everything works and should remain stable for the forseeable future. Please enjoy maxcolor:

maxcolor_demo

maxcolor 0.6.0

Updated dependencies to work with the other helper packages: maxconsole and max progress.

maxcolor 0.5.0

Purpose

This is a collection of helper scripts to work with rich renderables.


Features from Textualize/Rich:


  • Provides a helper function to allow for rich to easily print gradient text.
  • Provides a helper function to allow for rich to easily print a gradient text to a panel.

Installation


Install from Pip

pip install maxcolor

Install from Pipx

pipx install maxcolor

Install from Pipx

python add maxcolor



Usage


The following are available to import from maxcolor.

Color Regular Expressions

from maxcolor import HEX_REGEX, ANSI_REGEX, RGB_REGEX, COLOR_REGEX

hex_result = re.match(HEX_REGEX, "#FF0000")
ansi_result = re.match(ANSI_REGEX, "124")
rgb_result = re.match(RGB_REGEX, "255, 0, 0")
color_result = re.match(COLOR_REGEX, "#FF0000 123 255, 0, 0")

Color Conversion Functions

from maxcolor import hex_to_rgb, rgb_to_hex

rgb_color = hex_to_rgb("#FF0000") # (255, 0, 0)  # RGB tuple

hex_color = rgb_to_hex(255, 0, 0) # "#FF0000"  # Hex string

Gradient Color Functions

from maxcolor import gradient, rainbow, gradient_panel

console = get_console(get_theme())

console.print(
    gradient("Hello World!")
)

gradient.png

The gradient function will allow you to print multicolor gradients colored text. THe gradient function takes a string, an optional number of colors (defaults to 4), and an optional justification (defaults to "left").

The rainbow function is simply a the gradient function with the maximum number of colors, 10. And since it spans the entire color spectrum, it's a great way to print a rain.

console.print(
    gradient(
        "Sunt sit est labore elit ut laboris est. Aute cupidatat sit officia deserunt sint adipisicing et minim aliqua enim. Tempor eiusmod dolore excepteur dolore id aliquip enim incididunt ex. Non ipsum eu cillum proident ex. Officia deserunt consequat adipisicing est eiusmod nisi tempor aliquip proident ut in sunt nisi ullamco."
    )
)
console.print(
    rainbow(
        "Sunt sit est labore elit ut laboris est. Aute cupidatat sit officia deserunt sint adipisicing et minim aliqua enim. Tempor eiusmod dolore excepteur dolore id aliquip enim incididunt ex. Non ipsum eu cillum proident ex. Officia deserunt consequat adipisicing est eiusmod nisi tempor aliquip proident ut in sunt nisi ullamco.\n\n"
    )
)

Gradient (top text)


gradient_rainbow

Rainbow (bottom text)



Gradient Panel

Sometimes you need something more formal than a gradient, though. For that, you can use the gradient_panel function. This function takes a string, an optional number of colors (defaults to 4), and an optional justification (defaults to "left"). It will return a panel with the gradient text, and optionally, gradient title.

text = "\tEnim tempor veniam proident. Reprehenderit deserunt do duis laboris laborum consectetur fugiat deserunt officia officia eu consequat. Aute sint occaecat adipisicing eu aute. Eu est laborum enim deserunt fugiat nostrud officia do ad cupidatat enim amet cillum amet. Consectetur occaecat ex quis irure cupidatat amet occaecat ad sit adipisicing pariatur est velit mollit voluptate. Eiusmod deserunt nisi voluptate irure. Sunt irure consectetur veniam dolore elit officia et in labore esse esse cupidatat labore. Fugiat enim irure ipsum eiusmod consequat irure commodo cillum.\n\n\tReprehenderit ea quis aliqua qui labore enim consequat ea nostrud voluptate amet reprehenderit consequat sunt. Ad est occaecat mollit qui sit enim do esse aute sint nulla sint laborum. Voluptate veniam ut Lorem eiusmod id veniam amet ipsum labore incididunt. Ex in consequat voluptate mollit nisi incididunt pariatur ipsum ut eiusmod ut cupidatat elit. Eu irure est ad nulla exercitation. Esse elit tempor reprehenderit ipsum eu officia sint.\n\n\tCupidatat officia incididunt cupidatat minim fugiat sit exercitation ullamco occaecat est officia ut occaecat labore. Id consectetur cupidatat amet aute. Pariatur nostrud enim reprehenderit aliqua. Elit deserunt excepteur aute aliquip."

console.print(
    gradient_panel(
        text,
        title="Hello World",
        title_align = 'center',
        subtitle = "The Cake is a Lie".
        subtitle_align = 'right'
        num_of_gradients = 4,
        justify = "left"
        width = None
    )
)

gradient_panel

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

maxcolor-1.0.2.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

maxcolor-1.0.2-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file maxcolor-1.0.2.tar.gz.

File metadata

  • Download URL: maxcolor-1.0.2.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.2 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.13 tqdm/4.64.1 importlib-metadata/5.2.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.11.0

File hashes

Hashes for maxcolor-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c85a18093b7e4d6ab969914e21663e6aeee3aba5673f10ac21cda8d37437f47d
MD5 443e457589e8c69ad4cf8fdce80c9851
BLAKE2b-256 8a3d04e2f9da6637f92751c9f2e620c14a474529eb2fe707f876c3da06429c81

See more details on using hashes here.

File details

Details for the file maxcolor-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: maxcolor-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.2 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.13 tqdm/4.64.1 importlib-metadata/5.2.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.11.0

File hashes

Hashes for maxcolor-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d1cde491a1eb1c6eae65ad83b78e451dd90dbe92e08051943fb4b5aebabd77d
MD5 6cdf363378099b6e44c1aba2631bcfb6
BLAKE2b-256 cb8dec938a5bac4a451757a41fef6d4b17c0cb8f480d4a14530939ed204449e6

See more details on using hashes here.

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