var requiredFrames = 720;
var squareSize = min(windowWidth, windowHeight);
createCanvas(squareSize, squareSize);
gB = createGraphics(gBRes = 2048, gBRes);
gN = createGraphics(gBRes, gBRes);
v1 = random(-2, 2) * random();
v2 = random(-2, 2) * random();
v3 = random(-2, 2) * random();
v4 = random(-2, 2) * random();
var animationProgress = map((frameCount / requiredFrames) % 1, 0, 1, 0, TAU);
gB.translate(gBRes * 0.5, gBRes * 0.5);
gB.rotate(animationProgress);
var x2 = v1 * sin(animationProgress) * gBRes,
y2 = v2 * cos(animationProgress) * gBRes;
var x3 = v3 * cos(animationProgress) * gBRes,
y3 = v4 * sin(animationProgress) * gBRes;
gB.stroke(0, map(animationProgress, 0, TAU, 360, 0));
gB.strokeWeight(map(animationProgress, 0, TAU, 0, 6));
gB.fill(360, map(animationProgress, 0, TAU, 2, 0));
gB.bezier(x1, y1, x2, y2, x3, y3, x4, y4);
if (frameCount === requiredFrames) {
for (var i = 0; i < 6; i += 1) {
var xP = gBRes * random();
var yP = gBRes * random();
gN.stroke(map(yP, 0, gBRes, 330, 180) + 30 * random(), 30);
gN.strokeWeight(1 + random() * random());
for (var j = 0; j < 128; j += 1) {
xP += random(-1, 1) * noise(0.1 * xP, 0.1 * yP);
yP += random(-1, 1) * noise(0.1 * xP, 0.1 * yP);
var theta = map(noise(xP * 0.01 + frameCount, yP * 0.01 + frameCount), 0, 1, 0, TAU) * random(TAU);
function displayBuffer(buffer) {
var squareSize = min(windowWidth, windowHeight);
image(buffer, squareSize / 2, squareSize / 2, squareSize, squareSize);
function windowResized() {
var squareSize = min(windowWidth, windowHeight);
resizeCanvas(squareSize, squareSize);
function mouseClicked() {