import sys, math, time
from PyQt6.QtWidgets import QApplication, QWidget
from PyQt6.QtGui import QPainter, QColor
from PyQt6.QtCore import QTimer

class PlasmaDemo(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Plasma Demo")
        self.resize(1000, 1000)

        self.timer = QTimer()
        self.timer.timeout.connect(self.update)  # calls paintEvent repeatedly
        self.timer.start(18)  # ~60 FPS

        self.start_time = time.time()

    def paintEvent(self, event):
        painter = QPainter(self)
        t = time.time() - self.start_time

        for y in range(0, self.height(), 3):
            for x in range(0, self.width(), 4):
                v = math.tan(x/20.0 + t) + math.tan(y/15.0 - t)
                color = QColor.fromHsv(int((v+2)*60) % 100, 250, 255)
                painter.fillRect(x, y, 3, 50, color)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    demo = PlasmaDemo()
    demo.show()
    sys.exit(app.exec())
