xxxxxxxxxx
40
/*
Mimi Yin NYU-ITP
Circular Pathway
*/
//Store x,y coordinates of current position
let x, y;
// Store angle of rotation
let angle;
// Store radius of circle (size)
let r;
function setup() {
createCanvas(windowWidth, windowHeight);
angle = 0;
r = height*0.67;
x = width / 2;
y = height / 2 - r;
}
function draw() {
background(255, 1);
fill(0);
// Move around the circle
angle += 0.005;
// Calculate x,y coordinates
//Method 1
x = cos(2*angle) * r + width / 2;
y = sin(angle) * r + height / 2;
//Method 2
// x += cos(angle);
// y += sin(angle);
// Draw a circle at x,y
ellipse(x, y, 5, 5);
}