Random position subordinated to random positions

Hi there,

Do you mean that you would like to position the boxes randomly to segment the height to of the canvas?
Something like this?

If so you could set a variable for the height of the first box,
give it a random value,
draw that box using the variable as the lower corner of the box,
remove the height of that box you’ve just drawn from the random range,
use that height to position the top corner of the next box,
calculate a random height for the next box in the remaining canvas space
and so on.

The random() function in processing allows you to set a upper and lower bounds for the range of values that you’d like to produce. i.e:

float value = random(lower_bounds, upper_bounds);

You can also make use of the built in static variables height and width within the draw loop, as these default to the height and width of the canvas defined by size() in setup()

Does that help?