Random position subordinated to random positions

So you’d want to have some sort of data structure for saving the positions of the boxes so that you can make a logical check against them so that none overlap.

You could create a 2D boolean array the same size as the canvas, and when you draw a box set those positions in the array to True (or false), that is, they contain a box.

Then when trying to draw the next box you can check for overlap using that array.

Really this would be kind of a brute force solution for finding valid positions but I think it may do the job?