xxxxxxxxxx
let xLeft = 0; // Starting position for the ellipse from the left
let xRight = 600; // Starting position for the ellipse from the right
let yUp = 600; // Starting position for the ellipse from the bottom
let yDown = 0; // Starting position for the ellipse from the top
function setup() {
createCanvas(600, 600);
}
function draw() {
background(220);
for (let i = 0; i < 1000; i += 10) {
noFill();
// Left and right ellipses
stroke('rgb(88,175,88)');
strokeWeight(4);
ellipse(xLeft, 300, 500 - i, 500 - i); // Ellipse from the left
ellipse(xRight, 300, 500 - i, 500 - i); // Ellipse from the right
// Up and down ellipses
stroke('rgb(88,175,88)');
strokeWeight(3);
ellipse(300, yUp, 500 - i, 500 - i); // Ellipse from the bottom
ellipse(300, yDown, 500 - i, 500 - i); // Ellipse from the top
}
// horizontal positions (left and right ellipses)
if (xLeft > width) {
xLeft = 0;
} else {
xLeft = xLeft + 3;
}
if (xRight < 0) {
xRight = width;
} else {
xRight = xRight - 3;
}
// vertical positions (up and down ellipses)
if (yUp < 0) {
yUp = height;
} else {
yUp = yUp - 3;
}
if (yDown > height) {
yDown = 0;
} else {
yDown = yDown + 3;
}
}