xxxxxxxxxx
28
function setup() {
createCanvas(600, 400);
}
function draw() {
background(100);
fill("white");
stroke("white");
// Sinusoid moves a circle up and down
var myOffset = height / 2;
var myAmplitude = 100;
var myFrequency = 1; // beats per second
var myPhase = 0;
line(0, myOffset, width, myOffset);
var circleY = myOffset + myAmplitude * sin(TWO_PI * (millis() / 1000.0) * myFrequency + myPhase);
circle(75, circleY, 50);
stroke("yellow");
line(0, myOffset - myAmplitude, width, myOffset - myAmplitude);
line(0, myOffset + myAmplitude, width, myOffset + myAmplitude);
}