xxxxxxxxxx
void setup() {
size(600, 400); // Set the size of the canvas
drawGridOfCircles(4, 6, 30); // Draw a 6x4 grid of circles with a radius of 50 pixels
}
void draw(){
frameRate(100);
stroke(255)
fill(random(255));
}
void drawGridOfCircles(int rows, int cols, float circleRadius) {
float spacingX = width / (float) (cols + 1);
float spacingY = height / (float) (rows + 1);
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
float x = spacingX * (j + 1);
float y = spacingY * (i + 1);
drawCircle(x, y, circleRadius);
fill(random(255),random(255),random(255));
}
}
}
void drawCircle(float x, float y, float radius) {
rect(x-3, y-47, 8, 8);
fill(random(255),random(255),random(255));
rectMode(CORNER)
rect(x-15, y-40, radius, radius);
fill(random(255),random(255),random(255));
ellipse(x, y, radius * 2, radius * 2);
fill(random(255),random(255),random(255));
}
void mousePressed() {
// Save the canvas as an image when the mouse is pressed
String filename = "baubles.png";
save(filename);
println("Image saved as: " + filename);
}