xxxxxxxxxx
function setup() {
createCanvas(820, 200);
}
function draw() {
background(100);
fill("white");
noStroke();
// Sinusoid moves a circle up and down
var yOffset = height/2;
var yAmplitude = 50;
var yFrequency = 0.01;
var circleY = yOffset + yAmplitude * sin(millis()*yFrequency);
circle(75,circleY, 50);
// Sinusoid changes a circle's radius
var rOffset = 100;
var rAmplitude = 50;
var rFrequency = 0.01;
var circleR = rOffset + rAmplitude * sin(millis()*rFrequency);
circle(200,100, circleR);
// Sinusoid changes a circle's color
var gOffset = 128;
var gAmplitude = 128;
var gFrequency = 0.01;
var gray = gOffset + gAmplitude * sin(millis()*gFrequency);
fill(gray);
circle(350,100, 100);
// Sinusoid changes a rotation angle
var aOffset = 0;
var aAmplitude = 45; // degrees
var aFrequency = 0.01;
var angle = aOffset + aAmplitude * sin(millis()*aFrequency);
fill("white");
push();
rectMode(CENTER);
translate(500,100);
rotate(radians (angle));
rect(0,0, 100,50);
pop();
}