print a rotating ascii donut to the console in python

main.py
import math
import time

def render_frame(A, B):
    """Render a frame of the rotating donut"""
    z = [0] * 1760
    b = [0] * 1760
    output = [''] * 50
    j = 0
    while j < 6.28:
        for i in range(0, 6.28, 0.07):
            cos_i = math.cos(i)
            sin_i = math.sin(i)
            cos_j = math.cos(j)
            sin_j = math.sin(j)
            sin_i_3 = sin_i * 3
            cos_i_3 = cos_i * 3
            cos_i_4 = cos_i * 4
            cos_j_2 = cos_j * 2
            x = int(40 + 30 * sin_i_3 * (cos_j_2 + cos_i_4) - sin_j * cos_i_3)
            y = int(12 + 15 * sin_i_3 * (sin_j * cos_i_4 - cos_j_2) - sin_i_3 * sin_i_4 - cos_i_3 * sin_j)
            o = x + 80 * y
            n = int(8 * ((sin_j * cos_i_4 + cos_j_2) * sin_i_3 - cos_j * cos_i_3))
            if 22 > y and y > 0 and x > 0 and 80 > x and B[o] <= z[o]:
                z[o] = B[o]
                output[y] = f"{output[y][:x]}{'[@%#*+=-:. '[n if n > 0 else 0]:1}" + f"{output[y][x + 1:]}"

        j += 0.02

    print("\033[2J")  # Clear the console before rendering the next frame
    print("\033[H")
    print("\n".join(output))
    time.sleep(0.05)

def rotate_donut():
    """Rotate the donut indefinitely"""
    A = 0 
    B = [0] * 1760
    while True:
        A += 0.07
        B = list(map(int,
            [ey + cos(A) * 18 / (cos(x-A) 
            + 9 - sin(E) / 8) for x in range(0, 1760)]))
        render_frame(A, B)

rotate_donut()
1443 chars
47 lines

gistlibby LogSnag