prettier bars

This commit is contained in:
Will McGugan 2020-10-16 12:32:15 +01:00
parent 509decea2b
commit ddea7878a9
3 changed files with 24 additions and 1 deletions

View file

@ -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)