xxxxxxxxxx
let interval = 400;
let prevMillis = 0;
let firstBeat = 0;
let count = 0;
let prevTime = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
if (millis() > prevTime + interval) {
count++;
if (count > 4) {
count = 1;
}
prevTime = millis();
}
background(100);
textSize(50);
text(firstBeat, width / 2, height / 2 - 50);
text(interval, width / 2, height / 2);
text(count, width / 2, height / 2 + 50);
}
function mousePressed() {
if (firstBeat == 0) {
firstBeat = millis();
}
interval = millis() - prevMillis;
prevMillis = millis();
console.log(interval);
}