Gradient Rule Reference¶
Bases: Rule
A Rule with a gradient background.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
Optional[str]
|
The text to display as the title. |
required |
title_style
|
StyleType
|
The style to apply to the title text. Defaults to NULL_STYLE. |
NULL_STYLE
|
colors
|
List[ColorType]
|
A list of color strings for the gradient. Defaults to empty list. |
None
|
thickness
|
int
|
Thickness level of the rule (0 to 3). Defaults to 2. |
2
|
style
|
StyleType
|
The style of the rule line. Defaults to NULL_STYLE. |
NULL_STYLE
|
rainbow
|
bool
|
If True, use a rainbow gradient regardless of colors. Defaults to False. |
False
|
hues
|
int
|
Number of hues in the gradient if colors are not provided. Defaults to 10. |
10
|
end
|
str
|
End character after the rule. Defaults to newline. |
'\n'
|
align
|
AlignMethod
|
Alignment of the rule. Defaults to "center". |
'center'
|
Source code in src/rich_gradient/rule.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
__rich_console__(console, options)
¶
Render the gradient rule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
console
|
Console
|
The console to render to. |
required |
options
|
ConsoleOptions
|
The console options. |
required |
Yields:
Name | Type | Description |
---|---|---|
RenderResult |
RenderResult
|
The rendered segments of the gradient rule. |
Source code in src/rich_gradient/rule.py
_parse_colors(colors, rainbow, hues)
¶
Parse colors for the gradient.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
colors
|
List[ColorType]
|
A list of color strings. |
required |
rainbow
|
bool
|
If True, use a rainbow gradient. |
required |
hues
|
int
|
Number of hues in the gradient. |
required |
Raises: ValueError: If any color is not a valid string. ColorParseError: If a color string cannot be parsed.
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: A list of hex color strings for the gradient. |