xxxxxxxxxx
23
function setup() {
createCanvas(windowWidth, windowHeight);
}
let periodSec = 1;
function draw() {
background(220, 20, 120);
let amplitude = width / 2;
let xOffset = width / 4;
let period = periodSec * getTargetFrameRate();
let floorTerm = floor(frameCount / period + 0.5);
let absTerm = abs(frameCount / period - floorTerm);
let x = 2 * absTerm * amplitude;
let y = height / 2;
ellipse(x + xOffset, y, 25);
}