From f1036a67f322ed806a5634ad55373dcca48733ea Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Mon, 16 Dec 2024 16:36:42 +0100 Subject: [PATCH] basic sine grid --- simulator/sine_grid.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 simulator/sine_grid.py diff --git a/simulator/sine_grid.py b/simulator/sine_grid.py new file mode 100644 index 0000000..89ffdd7 --- /dev/null +++ b/simulator/sine_grid.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import math +from color import Color +from matrix import Matrix +import random + +class Cell: + def __init__(self) -> None: + self.state: float = random.uniform(0, 10) + self.increment: float = random.uniform(0.1, 0.5) + self.factor: float = random.uniform(0.9, 1.1) + + def get_value(self) -> float: + return 1 + (math.sin(self.state) * self.factor) + + + +def main(): + m = Matrix() + cells = [Cell() for _ in range(2048)] + for index, cell in enumerate(cells): + m.drawPixel(index % 64, index // 64, Color( + round(cell.get_value()*255), + 0, + 0 + )) + m.show() + +if __name__ == '__main__': + main()