mirror of
https://github.com/Textualize/rich.git
synced 2025-08-04 01:58:24 +00:00
prettier bars
This commit is contained in:
parent
509decea2b
commit
ddea7878a9
3 changed files with 24 additions and 1 deletions
|
@ -6,6 +6,7 @@ Use Bar to renderer a sort-of cirlce.
|
|||
import math
|
||||
|
||||
from rich.bar import Bar
|
||||
from rich.color import Color
|
||||
from rich import print
|
||||
|
||||
|
||||
|
@ -14,5 +15,6 @@ SIZE = 40
|
|||
for row in range(SIZE):
|
||||
y = (row / SIZE) * 2 - 1
|
||||
x = math.sqrt(1 - y * y)
|
||||
bar = Bar(1, width=SIZE * 2, begin=1 - x, end=x, color="red")
|
||||
color = Color.from_rgb((y + 1) * 127, 0, 0)
|
||||
bar = Bar(1, width=SIZE * 2, begin=1 - x, end=x, color=color)
|
||||
print(bar)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue