Source code for BiblioPixelAnimations.cube.simplex

from bibliopixel.animation.cube import Cube

from noise import snoise4


[docs]class Simplex(Cube): def __init__(self, layout, freq=16, octaves=1, **kwds): super().__init__(layout, **kwds) self._step = 1 self._freq = float(freq) self._octaves = octaves
[docs] def pre_run(self): self._step = 0
[docs] def step(self, amt): for y in range(self.x): for x in range(self.y): for z in range(self.z): v = int(snoise4(x / self._freq, y / self._freq, z / self._freq, self._step / self._freq, octaves=self._octaves) * 127.0 + 128.0) c = self.palette(v) self.layout.set(x, y, z, c) self._step += amt