Animated Gradient Reference
AnimatedGradient¶
Bases: BaseGradient
A gradient that animates over time using rich.live.Live
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
renderables
|
Optional[List[ConsoleRenderable]]
|
Renderables to apply the gradient to. |
None
|
colors
|
Optional[List[ColorType]]
|
Foreground color stops for the gradient. |
None
|
bg_colors
|
Optional[List[ColorType]]
|
Background color stops for the gradient. |
None
|
auto_refresh
|
bool
|
Automatically refresh the Live context. Defaults to True. |
True
|
refresh_per_second
|
float
|
Refresh rate for the Live context. Defaults to 30.0. |
30.0
|
console
|
Optional[Console]
|
Console to use for rendering. Defaults to the global console. |
None
|
transient
|
bool
|
Keep Live transient (don’t clear on stop). Defaults to False. |
False
|
redirect_stdout
|
bool
|
Redirect stdout to Live. Defaults to False. |
False
|
redirect_stderr
|
bool
|
Redirect stderr to Live. Defaults to False. |
False
|
disable
|
bool
|
Disable rendering. Defaults to False. |
False
|
expand
|
bool
|
Expand to fill console width/height. Defaults to False. |
False
|
justify
|
AlignMethod
|
Horizontal justification. Defaults to "left". |
'left'
|
vertical_justify
|
VerticalAlignMethod
|
Vertical justification. Defaults to "top". |
'top'
|
hues
|
int
|
Number of hues when auto-generating colors. Defaults to 5. |
5
|
rainbow
|
bool
|
Use a rainbow gradient. Defaults to False. |
False
|
speed
|
int
|
Animation speed in milliseconds. Defaults to 4. |
4
|
show_quit_panel
|
bool
|
Show a quit instructions panel. Defaults to True. |
True
|
repeat_scale
|
float
|
Stretch color stops across a wider span. Defaults to 2.0. |
2.0
|
background
|
bool
|
Apply gradient to background instead of foreground. Defaults to False. |
False
|
Examples:
Or as a context manager:
Source code in src/rich_gradient/_animated_gradient.py
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
_animate()
¶
Run the animation loop, updating at the requested FPS until stopped.
Source code in src/rich_gradient/_animated_gradient.py
_gen_quit_panel()
¶
Generate a panel with instructions to quit the animation.
_generate_quit_subtitle()
¶
get_renderable()
¶
Return the renderable the Live instance should display each frame.
Source code in src/rich_gradient/_animated_gradient.py
run()
¶
Blocking helper: start, then wait for Ctrl+C, then stop.
start()
¶
Start the Live context and the animation loop in a background thread.
Source code in src/rich_gradient/_animated_gradient.py
stop()
¶
Signal the animation to stop, wait for the thread, and close Live.