let r, sound, cnv, level, amp;
sound = loadSound('the force trimmed 2 .mp3');
cnv = createCanvas(500, 500);
cnv.mousePressed(togglePlay);
amp = new p5.Amplitude();
diffCheck = createCheckbox('Difference');
bg = createCheckbox('Background');
function getVector(index, total) {
const angle = map(index % total, 0, total, 0, TWO_PI);
const v = p5.Vector.fromAngle(angle + PI);
if (diffCheck.checked()) {
translate(width / 2, height / 2);
for (let i = 0; i < total; i++) {
const a = getVector(i, total);
const b = getVector(i * factor, total);
wobble(a.x, a.y, b.x, b.y);
function wobble(x, y, a, b) {
level = map(amp.getLevel(), 0, 1, 1, 3);
total = map(amp.getLevel(), 0, 1, 10, 255);
x += random(-2 * zoff, 2 * zoff);
y += random(-2 * zoff, 2 * zoff);
a += random(-2 * zoff, 2 * zoff);
b += random(-2 * zoff, 2 * zoff);
line(x * r / width, y * r / height, a, b);
circle(a * level * 2, b * level * 2, x % y / 2);
circle(x * level * 1.25, y * level * 1.25, a % b / 1.25);