()
Runs this visualization without the need of the server running.
Runs this visualization without the need of the server running.
Runs this visualization without the need of the server running .
def main() -> None:
    """Runs this visualization without the need of the server running."""
    os.environ["EGL_PLATFORM"] = "x11"

    mock_cava = type(
        "obj",
        (object,),
        {
            "bars": 256,
            "current_frame": [0 for _ in range(256)],
            "use": lambda: ...,
            "release": lambda: ...,
        },
    )
    mock_manager = type(
        "obj",
        (object,),
        {
            "ups": 25,
            "cava_program": mock_cava,
            "alarm_program": type("obj", (object,), {"factor": -1}),
        },
    )
    circle = Circle(mock_manager)
    circle.start()
    seconds_per_frame = 1 / mock_manager.ups

    while True:
        computation_start = time.time()
        try:
            circle.draw()
        except RenderingStoppedException:
            break
        mock_cava.current_frame = [
            0.5 * (1 + math.sin(-4 * circle.time_elapsed + 0.5 * i))
            for i in range(len(mock_cava.current_frame))
        ]
        mock_cava.current_frame = [
            0.8
            * 0.5
            * (1 + math.sin(4 * circle.time_elapsed))
            * 0.5
            * (1 + math.sin(-4 * circle.time_elapsed + 0.2 * i))
            for i in range(len(mock_cava.current_frame))
        ]
        computation_time = time.time() - computation_start
        # print(f'time needed / avaliable: {computation_time / seconds_per_frame:0.2f}')
        try:
            time.sleep(seconds_per_frame - computation_time)
        except ValueError:
            pass
def main ( ) -> None : os . environ [ "EGL_PLATFORM" ] = "x11" mock_cava = type ( "obj" , ( object , ) , { "bars" : 256 , "current_frame" : [ 0 for _ in range ( 256 ) ] , "use" : lambda : ... , "release" : lambda : ... , } , ) mock_manager = type ( "obj" , ( object , ) , { "ups" : 25 , "cava_program" : mock_cava , "alarm_program" : type ( "obj" , ( object , ) , { "factor" : - 1 } ) , } , ) circle = Circle ( mock_manager ) circle . start ( ) seconds_per_frame = 1 / mock_manager . ups while True : computation_start = time . time ( ) try : circle . draw ( ) except RenderingStoppedException : break mock_cava . current_frame = [ 0.5 * ( 1 + math . sin ( - 4 * circle . time_elapsed + 0.5 * i ) ) for i in range ( len ( mock_cava . current_frame ) ) ] mock_cava . current_frame = [ 0.8 * 0.5 * ( 1 + math . sin ( 4 * circle . time_elapsed ) ) * 0.5 * ( 1 + math . sin ( - 4 * circle . time_elapsed + 0.2 * i ) ) for i in range ( len ( mock_cava . current_frame ) ) ] computation_time = time . time ( ) - computation_start # print(f'time needed / avaliable: {computation_time / seconds_per_frame:0.2f}') try : time . sleep ( seconds_per_frame - computation_time ) except ValueError : pass