xxxxxxxxxx
67
// Inspired by Roni Kaufman
let kMax = 0.96;
let frameSpeed;
let timeLoopNumber = 38; // number of time loops
let diameter; // for the time loops
let interLoop = 0.005; // space between individual loops
let maxNoise = 222; // distance of perlin noise
let sound;
function preload() {
sound = loadSound("nuvolebianche.mp3");
}
function setup() {
colorMode(HSB, 0.45);
angleMode(RADIANS);
noFill();
sound.loop();
// console.log(sound.isLoaded());
}
function draw() {
background("black");
// stroke("white");
// strokeWeight(0.05);
// ellipse(windowWidth / 2, windowHeight / 2, windowWidth / 5, windowHeight / 5);
let diameter = windowWidth / 10;
strokeWeight(0.2);
for (let i = 0; i < timeLoopNumber; i++) {
let loopSize = diameter + i * interLoop;
let alpha = 1.25 - 1.5 * (i / timeLoopNumber); // loops fade outwards
stroke(0.2, alpha);
let k = kMax * (i / timeLoopNumber);
let perlin = maxNoise * (i / timeLoopNumber);
timeLoop(loopSize, width / 2, height / 2, k, i, perlin);
}
}
function timeLoop(loopSize, xpos, ypos, k, kMax, perlin) {
beginShape();
let angleInc = PI * 0.015;
let frameSpeed = frameCount / 333;
for (let theta = 0; theta < PI * 2; theta += angleInc) {
let angle1, angle2;
//square shape, waves towards middle
angle1 = cos(theta * 4) + PI * 0.35;
angle2 = sin(theta * 4) + PI * 0.35;
let amp =
loopSize +
noise(frameSpeed + k * angle1, frameSpeed + k * angle2) * perlin;
let x = xpos + amp * cos(theta);
let y = ypos + amp * sin(theta);
curveVertex(x, y);
}
endShape(CLOSE);
}
}