SIGN IN SIGN UP
Textualize / rich UNCLAIMED

Rich is a Python library for rich text and beautiful formatting in the terminal.

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