xxxxxxxxxx
33
let radius = 0
let angle = 0
let motion = 1
const speed = 0.05
let centerX
let centerY
function setup() {
createCanvas(600, 600);
centerX = width / 2
centerY = height / 2
}
function draw() {
// background(220);
ellipse(width / 2, height / 2, 10, 10)
var x = centerX + radius * sin(angle)
var y = centerY + radius * cos(angle)
ellipse(x, y, 50, 50)
if (radius >= 150 && motion === 1) {
motion = -1
} else if (radius <= 0) {
motion = 1
}
radius+= motion
angle = angle + speed
}