Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
This library is a wrapper of the great rich library that extends rich.text.Text to allow for the easy generation gradient text from either user entered colors or randomly if no colors are entered.
Borrowing from pydantic-extra-types' Color class, rich_gradient extends the rich standard colors to include:
#f00
or #ff0000
)rgb(255, 0, 0)
)(255, 0, 0)
)red
)Read the docs at rich-gradient.readthedocs.io
rye add rich-gradient
pip install rich-gradient
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!")
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 can be parsed from a variety of formats including:
console.print(
Gradient(
"This a gradient with specific colors.",
colors=["red", "#ff9900", "#ff0", "Lime"],
justify="center"
)
)
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.
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()
FAQs
A gradient generator for the Rich library.
We found that rich-gradient demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.