I made something similar in the past:
Code:int MIN_RAD = 10;
int MAX_RAD = 100;
int MAIN_RAD = 250;
int CIRCLE_NB = 222;
void setup()
{
size(500, 500);
background(255);
noStroke();
int centerX = width / 2;
int centerY = height / 2;
for (int i = 0; i < CIRCLE_NB; i++)
{
float d = random(0, MAIN_RAD - MIN_RAD);
float a = random(0, TWO_PI);
float x = centerX + d * cos(a);
float y = centerY + d * sin(a);
float r = random(MIN_RAD, min(MAX_RAD, MAIN_RAD - d));
color c = lerpColor(#00FF00, #0000FF, (1 + cos(a))/2);
fill(c);
ellipse(x, y, r * 2, r * 2);
}
}
But it is limited to a circle shape...
For more complex shapes, a classical way is to draw it on a PGraphics in a monochrome way and use the corresponding array of pixels as a boolean array: one color = in shape, background color = out of shape.
Then you can draw random numbers and reject them if out of shape, or make an array of bounds (for each line of pixels, pair(s) of start of shape/end of shape coordinates), etc.
Processing doesn't offer a ShapeLayout class out of the box, it is a rater low level (pixel level, as opposed to scenegraph level) framework.