xxxxxxxxxx
39
var theta;
var speed;
var baseDiameter;
var pulseAmplitude;
function setup() {
createCanvas(500, 500);
// Initialize all values
r = height * 0.45; // the radius of the circle
theta = 0;
speed = .02;
baseDiameter = 32;
pulseAmplitude = 16;
}
function draw() {
background(244,132,140);
//background(0);
// Translate the origin point to the center of the screen
translate(width/2, height/2);
// Convert polar to cartesian
var x = r * cos(theta);
var y = r * sin(theta);
var diam = baseDiameter + sin(theta*4) * pulseAmplitude;
// Draw the ellipse at the cartesian coordinate
ellipseMode(CENTER);
fill(255);
ellipse(x, y, diam, diam);
// Apply speed to theta
theta += speed;
}