randomly position objects on-screen

Dar Scott dsc at swcp.com
Fri May 31 14:24:07 EDT 2013

If the controls are relatively small compared to your area, you can guess a lot and then fallback to something when you hit your limit in failures.  That can also work if space is tight if failing is smart and you can take the time to try several.  

For a 1D problem, I'd randomly select the left margin (the distance to the left, not the property) after randomly selecting the order of controls.  The first left margin is taken from all the space left over after looking at the widths.  The second is take from the space left over after that.  And so on.  

There might be something similar with 2D, but that looks more challenging.  


On May 31, 2013, at 11:49 AM, Chris Sheffield wrote:

> Okay, I figure someone out there has probably done this before, so I thought I'd ask here before I dive in to the deep end (or go off the deep end, whichever comes first).
> Given a rectangular area (in this case a graphic object), I need to randomly position three controls (in this case Scott's tmControl buttons (groups)), within that area. It's not a huge area to work with, but the controls are not too big. The conditions are that the controls cannot intersect (overlap) and they have to be completely visible within the given area (not partially off-screen).
> Any takers?
> Thanks,
> Chris
> --
> Chris Sheffield
> Read Naturally, Inc.
> www.readnaturally.com
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

More information about the use-livecode mailing list