var gB, fullRes, windowRes;
var requiredFrames = 180;
windowRes = min(windowWidth, windowHeight);
createCanvas(windowRes, windowRes);
gB = createGraphics(fullRes = 64, fullRes);
function randPow(multiplier, min, max, power) {
for (var i = 0; i < power; i += 1) {
multiplier *= random(min, max);
let currentFrame = (frameCount / requiredFrames) % 1;
gB.translate(fullRes * 0.5, fullRes * 0.5);
for (let i = 0; i < 1; i += 1 / lines) {
gB.rotate(map((currentFrame + i) % 1, 0, 1, 0, TAU));
gB.rotate(map((currentFrame + i) % 1, 1, 0, 0, TAU));
for (let j = 0; j < 512; j += 1) {
let distance = random() * random(fullRes * 0.5, fullRes);
theta = randPow(TAU, 0, 1, 4);
theta = -randPow(TAU, 0, 1, 4);
let brightnessValue = map(distance, 0, fullRes, 360, 0);
gB.stroke(0, 360, brightnessValue);
} else if (phase % 3 === 1) {
gB.stroke(120, 360, 0.25 * brightnessValue);
gB.stroke(240, 360, brightnessValue);
gB.point(distance * cos(theta), distance * sin(theta));
saveGif('export', requiredFrames, {
function displayBuffer(buffer) {
image(buffer, windowRes / 2, windowRes / 2, windowRes, windowRes);
function windowResized() {
windowRes = min(windowWidth, windowHeight);
resizeCanvas(windowRes, windowRes);