I need some ideas in order to finish algorithm. I'm randomly placing objects (bitmaps) on canvas without overlapping. Time needed to finish it is my problem. When I need to spawn for example 80% of canvas it takes to long. So i was thinking : I should make some change when the bitmaps take off 50 % of canvas. I want to tell algorithm that it should generate new locations (x,y) where it is free space.
My question is : How to render new location (x,y) in place where is free space.
Things I know :
- object location (x,y)
- 4 corners (x,y) of object
- object width, height
- canvas width, height
Thanks for ideas. Now I've got problem.
OK, thanks for ideas. I've got a problem.
Link to picture: Picture with grid
I'm incrementing number of objects in cell after each adding object to grid. In the picture there are 9 possible locations for object. Should I check 9 conditions which tells where I should increment number of objects in cell? I assume that if object is on both cells than I increment number of objects in both cells.