Random circles using arrays


So I have these tasks: 1. When the sketch starts, a circle with a random size, position and border color is
displayed in the window and a first circle with a radius of 10 pixels on the mouse
2. Every two seconds a new circle with a random border color (no white!) and
random radius (between 10 and 50) will appear at a random position in the

So far, I have this:

int counter=120;
int numCircles = 50;
int x, y;
int[] myArr = new int[numCircles];

void setup() {
  size(500, 500);

void initializeArray(int[] someArr) {
  for (int i=1; i < someArr.length; i++) {
    someArr[0] = 10;
    someArr[i] = (int)random(10, 50);

void draw() {
  //ellipse(mouseX, mouseY, 10, 10);

void generateCircles(int[] someArr) {
  x = (int)random(width);
  y = (int)random(height);
  for (int i=1; i < someArr.length; i++) {
    drawCircle(x, y, someArr[i]);

void drawCircle(int x, int y, int radius) {
  for (int i=0; i <= counter; i++) {
    ellipse(x, y, radius, radius);

The issues I’m currently facing are those: 1. Framerate seems to be 240fps instead of default 60, although I haven’t changed it neither in the code nor settings.
2. When I try to draw an ellipse in the mouse position, it updates at the same time as the other circles (these are updating using counter), it doesn’t matter where I put the command.
3. Circles with random position are drawn on top of each other 2-3 times and then moves all together instead of drawing one every 2 seconds.

Any advice?

1 Like


void draw() {

to see your actual frame rate.


in setup to change it.

  1. drawing a circle on mouseclick would be
void mousePressed() {
 ellipse(mouseX, mouseY, 10, 10); 

could be a idea, but just for 1/60 sec
as the background erases it / anyhow not the job ? at start?? mouse position

  1. yes,
  • you draw many circles at the same position with generateCircles
  • you draw these 60 times per second so it looks like they are jumping around
    but if you disable background you see 60 times this concentric circles add up per second…

so over all you add 2 * 60 * ?50? circles
instead 1
every 2 secs

1 Like