2020-10-16 09:56:08 +00:00
|
|
|
"""
|
|
|
|
|
2020-10-16 14:58:46 +00:00
|
|
|
Use Bar to renderer a sort-of circle.
|
2020-10-16 09:56:08 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
import math
|
|
|
|
|
2020-10-16 14:58:46 +00:00
|
|
|
from rich.align import Align
|
2020-10-16 09:56:08 +00:00
|
|
|
from rich.bar import Bar
|
2020-10-16 11:32:15 +00:00
|
|
|
from rich.color import Color
|
2020-10-16 09:56:08 +00:00
|
|
|
from rich import print
|
|
|
|
|
|
|
|
|
|
|
|
SIZE = 40
|
|
|
|
|
|
|
|
for row in range(SIZE):
|
2020-10-16 14:58:46 +00:00
|
|
|
y = (row / (SIZE - 1)) * 2 - 1
|
2020-10-16 09:56:08 +00:00
|
|
|
x = math.sqrt(1 - y * y)
|
2020-10-16 11:32:15 +00:00
|
|
|
color = Color.from_rgb((y + 1) * 127, 0, 0)
|
2020-10-16 14:58:46 +00:00
|
|
|
bar = Bar(2, width=SIZE * 2, begin=1 - x, end=1 + x, color=color)
|
|
|
|
print(Align.center(bar))
|