Loop & bg problem

Alright, why don’t you try using an array of PVectors instead of vertices? Both vertex() and PVector() hold two values, one for x, one for y. Try creating a PVector[] vertices = new PVector[0]; (before the setup(){} )then use

 int n_vertex = int(random(7, 20));
vertices = new PVector[n_vertex];
    beginShape();
    for (int i = 0; i < n_vertex; i++) {
    vertices[i] = new PVector(random(width), random(height));
    }

instead of

int n_vertex = int(random(7, 20));

    beginShape();
    for (int i = 0; i < n_vertex; i++) {
    vertex(random(width), random(height));
    }
    
    endShape(CLOSE);

and for the other condition (high> bass) as well.
Then, right before the end of the draw loop, use

if(vertices.length > 0){
  beginShape();
  for(int i = 0; i< vertices.length; i++){
   vertex(vertices[i].x, vertices[i].y); 
  }
  endShape(CLOSE);
}

This should work, because every time a new shape is created, its vertices are stored in an array, in the form of PVectors. This way, you can draw it anytime. Hope this helps.