Place random non-overlapping rectangles on a panel

后端 未结 5 878
别那么骄傲
别那么骄傲 2020-12-05 11:44

I\'ve a panel of size X by Y. I want to place up to N rectangles, sized randomly, upon this panel, but I don\'t want any of them to overlap. I need to know the X, Y position

5条回答
  •  时光取名叫无心
    2020-12-05 12:15

    Or maintain a list of rectangles already added and create an algorithm that figures out where to place the new rectangle based on that list. You can create a basic Rectangle class to hold the information about your rectangles.

    Shouldn't be so hard to create a custom algorithm.

提交回复
热议问题