Gradient Reference¶
maxgradient.gradient.Gradient is at the core of MaxGradient. Gradient is a subclass of rich.text.Text, and can be used in the same way. The Gradient class however also incorporates maxgradient.color.Color which is an expanded version of rich.color.Color. Gradient can be used to create a gradient of colors or styles. Gradient can also be used to create a rainbow effect, or to invert the colors of the gradient.
Initialize¶
class Gradient (
self ,
text: Optional[str|rich.text.Text] = "",
colors: Optional[List[Color|Tuple|str]|str] = None,
rainbow: bool = False,
hues: Optional[int] = None,
color_sample: bool = False,
style: StyleType = rich.text.Style.null(),
*,
justify: Optional[str] = None,
overflow: Optional[str] = None,
no_wrap: Optional[bool] = None,
end: str = "\n",
tab_size: Optional[int] = 8,
spans: Optional[List[Span]] = None ) -> None:
self ,
text: Optional[str|rich.text.Text] = "",
colors: Optional[List[Color|Tuple|str]|str] = None,
rainbow: bool = False,
hues: Optional[int] = None,
color_sample: bool = False,
style: StyleType = rich.text.Style.null(),
*,
justify: Optional[str] = None,
overflow: Optional[str] = None,
no_wrap: Optional[bool] = None,
end: str = "\n",
tab_size: Optional[int] = 8,
spans: Optional[List[Span]] = None ) -> None:
Parameters¶
Parameters | Description |
---|---|
text | The text to be displayed in gradient color. Can be entered as a string or as an instance of rich.text.Text . Defaults to an empty string. |
colors | The colors from which to create the gradient. Can be entered as a list of:
|
rainbow | Whether or not to create a rainbow gradient. Defaults to False. |
hues | The number of hues to use when creating a random gradient. Defaults to None, which will result in a gradient of three colors. |
style | The style of the text. Unlike Text object where this could determine color, only styles such as bold, underline, or italic will do anything. |
justify | The justification of the text. Can be one of:
|
overflow | The overflow of the text. Can be one of:
|
no_wrap | Whether or not to wrap the text. Defaults to None, which will result in the text being wrapped. |
end | The string to be appended to the end of the text. Defaults to \n . |
tab_size | The number of spaces to be used when a tab is encountered. Defaults to 8. |
spans | A list of rich.text.Span objects. Defaults to None. |
Methods¶
Gradient.as_text()¶
as_text() returns the gradient as a rich.text.Text
object.