Add your description here
Project description
This library is a wrapper of the great rich library that extends rich.text.Text to allow for the easy generation gradient text from the user inputed colors or randomly if not colors are presented.
Borrowing from pydantic-Looextra-types' Color class, rich_gradient extends the rich standard colors to include:
- 3 or 6 digit hex code (e.g.
#f00
or#ff0000
) - RGB color codes (e.g.
rgb(255, 0, 0)
) - RGB tuples (e.g.
(255, 0, 0)
) - CSS3 Color Names (e.g.
red
)
Read the docs at rich-gradient.readthedocs.io
Installation
Rye (Recommended)
rye add rich-gradient
Pip
pip install rich-gradient
Usage
Basic Gradient Example
To print a simple gradient just substitue the Gradient
class for the Text
class in the rich library.
from rich.console import Console
from rich_gradient import Gradient
console = Console()
console.print(Gradient("Hello, World!")
Gradient with Specific Colors
If you want a bit more control of the gradient, you can specify the colors you want to use in the gradient by passing them as a list of colors to the colors
parameter.
Color Formats
Color can be parsed from a variety of formats including:
Example Code
console.print(
Gradient(
"This a gradient with specific colors.",
colors=["red", "#ff9900", "#ff0", "Lime"],
justify="center"
)
)
Specific Color Gradient Result:
Rainbow Gradient Example
If four colors isn't enough, you can use the 'rainbow' parameter to generate a rainbow gradient that spans the entire spectrum of colors randomly.
console.print(
Gradient(
"This is a rainbow gradient.",
rainbow=True,
justify="center"
)
)
*The rainbow gradient is generated randomly each time the code is run.
Still inherits from rich.text.Text
Since Gradient
is a subclass of Text
, you can still use all the same methods and properties as you would with Text
.
console.print(
Gradient(
"This is an underlined rainbow gradient.",
rainbow=True,
style="underline"
),
justify="center"
)
console.line()
console.print(
Gradient(
"This is a bold italic gradient.",
style="bold italic"
),
justify="center"
)
console.line()
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
Built Distribution
File details
Details for the file rich_gradient-0.1.1.tar.gz
.
File metadata
- Download URL: rich_gradient-0.1.1.tar.gz
- Upload date:
- Size: 916.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d686b62dc93ba9e35c6c86c5b75ae5072c857b52ba34a40b93d0cf478a44bdc |
|
MD5 | 614f5c9584fd36756d0c9358d163802d |
|
BLAKE2b-256 | f248d71541c654e533fd41df99331c1ea3df99715ca1de97b9dca4555831817a |
Provenance
File details
Details for the file rich_gradient-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: rich_gradient-0.1.1-py3-none-any.whl
- Upload date:
- Size: 31.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 979b6d82d56dc6835ba683f7763d35ae6effd071ec393494b3f497333e823523 |
|
MD5 | 83717e6e0d8dee088ead1aee3c9a2d33 |
|
BLAKE2b-256 | 53cea1bccdcc0eff1ccb59e072b1a40e4c321b00c6629e7d7b46a6c89e34b2eb |