xxxxxxxxxx
109
let bubbles = [];
let centralCirclePosition;
let centralCircleRadius;
function setup() {
createCanvas(700, 700);
centralCirclePosition = createVector(width / 2, height / 2);
centralCircleRadius = 200; // Adjust the size of the central circle
}
function mousePressed() {
let r = random(30, 70); // Make bubbles bigger
let newColor = color(random(255), random(255), random(255)); // Generate a random color
let b = new Circle(mouseX, mouseY, r, newColor); // Pass the random color to the Circle
bubbles.push(b);
}
function draw() {
background(220);
// Draw bubbles
for (let bubble of bubbles) {
bubble.move();
bubble.show();
}
// Draw central circle
stroke(0);
strokeWeight(1);
drawCentralCircle();
stroke(0);
fill(225);
strokeWeight(1);
let leftEyePosition = ellipse(270, 340, 50,100);
let rightEyePosition = ellipse(330, 340, 50, 100);
stroke(0);
fill(0);
strokeWeight(1);
circle(260,340,20);
circle(320,340,20);
stroke(0);
fill("rgb(141,141,233)");
strokeWeight(1);
arc(250,270,350,50,0,180,PI,CHORD);
stroke(0);
fill('rgb(73,73,146)');
strokeWeight(1);
arc(335,270,400,320,PI,0, PI+QUARTER_PI, OPEN);
stroke(0);
fill(0);
strokeWeight(1);
circle(320,110,20);
stroke(0);
strokeWeight(1);
arc(500,450,100,100,HALF_PI,)
fill(255);
stroke('red');
strokeWeight(4);
arc(300,450,100,45,0,PI, CHORD);
stroke('brown')
ellipse(540,390,60,250)
triangle(540,270,460,230,460,310)
triangle()
}
class Circle {
constructor(x, y, r, color) {
this.x = x;
this.y = y;
this.r = r;
this.color = color;
}
move() {
this.x = this.x + random(-2, 2);
this.y = this.y + random(-2, 2);
}
show() {
strokeWeight(1)
stroke(0)
fill(this.color);
ellipse(this.x, this.y, this.r * 2);
}
}
function drawCentralCircle() {
let colorOfCircle = color(200, 100, 100); // Default color
if (dist(mouseX, mouseY, centralCirclePosition.x, centralCirclePosition.y) < centralCircleRadius) {
colorOfCircle = color(mouseX % 255, mouseY % 255, 200); // Change color dynamically based on mouse position
}
fill(colorOfCircle);
ellipse(centralCirclePosition.x, centralCirclePosition.y, centralCircleRadius * 2);
}