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[str|List[Color | Tuple | str]] = None,
rainbow: bool = False,
invert: bool = False,
hues: Optional[int] = None,
color_sample: bool = False,
style: StyleType = Style.null(),
*,
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.
Color
The final main component of MaxGradient is expanding the rich.color.Color class. The MaxGradient .Color class can still parse and utilize 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 convenience. The follow are the available named colors as well as there hex and rgb colors:
Color Examples
import maxgradient as mg
console = mg.Console()
console.print("[bold green]This is a a vibrant green color!")
Changelog v1.0.6
- Added docs
- Changed docs to readthedocs theme.