VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Occupied Space concept used to allocate 100 labels randomly w/o overlapping (no API)

by pietro ing. cecchi (8 Submissions)
Category: Math/Dates
Compatability: Visual Basic 3.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

Populates form area with labels, using the 'unoccupied space' concept, instead of intersection.
Any added item, while populating the screen, takes a cell from the 'unoccupied space', resulting
in a much faster process than intersection. Nice to see.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
idea proposed by Gunnar [email protected], SECOND EMAIL:
Pietro, one more thing:
What i really, originally was thinking, was to be able
to
1. Press a button, and choose a number to allocate,
let's say 20 labels, then
2. Press the button again if one likes, and chose
another number to allocate, let's say 12.
..
..
3. Press (any) more times, until the MaxObjectIndex is
reached (or, when it's not possible to allocate more
without collision).
And then the question (from my earlier mail) would
come (yes/no/cancel).
The program would know from the first time, where to
find the "unoccupied space".
I guess this would take some kind of storing the
occupied spaces or something
if i should be able to use the code, it has to be done
with (invisible) objects placed at design-time (100),
not loaded :)
I wish you many votes at VBC, i know you got mine !
/Gunnar.
FIRST EMAIL WAS (which originated my post: How to allocate HUNDREDS rectangles (labels, images...) without overlapping, no API!):
Hello Pietro !
I was studying your excellent code-example of the
rectangle-Intersections.
I got inspired by it, and i have a problem in my
application, but i do not know how to code it, i was
thinking maybe you could help me.
* I have an array of labels
* I also have a function to place the labels out
randomly over the screen
Private sub Place_Labels
Dim lIndex As Long
Randomize timer
For lIndex = 0 To cmd.Count - 1
cmd(lIndex).Move (Rnd * (ScaleWidth -
cmd(lIndex).Width)), (Rnd * (ScaleHeight -
cmd(lIndex).Height))
Next
End sub
This procedure sometimes places the labels "on top of
eachother".
1) I would like to add some code to prevent
collisions, so that every labels is placed on a
separate position.
Maybe your code could help me here, but i do not
really know how to do this,
i think i'd have to go through all of my labels, and
check if there is already
a label placed there, but i have no idea of how to
code this.
Can you help me ?
thanks in advance !
Best regards from sweden,
Gunnar.
++++++++++++++++++++++++++++++++++++++++++++++++++
This program has been written down in Visual Basic 6.
I hope yow like the effort, have fun :)

Rate Occupied Space concept used to allocate 100 labels randomly w/o overlapping (no API)

Download Occupied Space concept used to allocate 100 labels randomly w/o overlapping (no API)

Download Occupied Space concept used to allocate 100 labels randomly w/o overlapping (no API) (17 KB)

Occupied Space concept used to allocate 100 labels randomly w/o overlapping (no API) Comments

No comments have been posted about Occupied Space concept used to allocate 100 labels randomly w/o overlapping (no API). Why not be the first to post a comment about Occupied Space concept used to allocate 100 labels randomly w/o overlapping (no API).

Post your comment

Subject:
Message:
0/1000 characters