# Quantum Static Visualizer
import pygame
import os
import json
import random
import colorsys
from entropy_pool import load_pool as load_entropy_pool


def run():
    # Load entropy data
    pool = load_entropy_pool()
    if not pool:
        return

    # Pygame setup
    pygame.init()
    WIDTH, HEIGHT = 800, 600
    screen = pygame.display.set_mode((WIDTH, HEIGHT))
    pygame.display.set_caption("Quantum Static Visualizer")

    clock = pygame.time.Clock()
    running = True

    pool_index = 0
    pixel_size = 4  # Size of each pixel block

    # Generate pixel grid (resize pool to match screen)
    num_pixels = (WIDTH // pixel_size) * (HEIGHT // pixel_size)

    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False

        # Draw static
        for y in range(0, HEIGHT, pixel_size):
            for x in range(0, WIDTH, pixel_size):
                value = pool[pool_index % len(pool)]
                color = (value, value, value)  # Grayscale
                pygame.draw.rect(screen, color, (x, y, pixel_size, pixel_size))
                pool_index += 1

        pygame.display.flip()
        clock.tick(1)  # Update once per second (slow-moving static)

    pygame.quit()

