I'm spaced out!
September 29, 2005 3:10 PM
Subscribe
Programming/geometry: in a Flash program (you don't need to know Flash to answer this), I'm trying to place rectangular images at random positions on the screen. There are already images on the screen. I need to make sure that the new, randomly-placed images don't obscure the images already there.
So I've got a rectangular screen and I know its width and height. I also know the x,y coordinates of each image already on that screen. And I know each image's width and height. I also know the dimensions of all the images not yet placed.
New images (and already placed items) are NOT all the same size (different widths & heights). Which makes things difficult.
So lets say I need to place a 100px by 200px image on the stage. I need to somehow generate a list of all the 100x200px (or greater) free areas. Then I just need to randomly pick one of those areas and place the new image in it. That last part's east. It's finding the free space that's confusing me.
Given the info I have (x/y coords, w/h of screen, w/h of images), how do I proceed?
So, before placing a new image
posted by grumblebee to computers & internet (25 comments total)
posted by Capn at 3:20 PM on September 29, 2005