Is there an algorithm or coding example that may help me here?

Hi I am working on a personal project and I was hoping to get some help trying to wrap my head around how best to go about this part of the project.

So what I am envisioning:

  1. The program is given a string array (completed)

  2. The program will then take the string array and in random parts of the display area create a text object that displays the current string at stringArray[i] (completed)
    3.The text objects should be varying sizes (3-4 text sizes) (completed)

  3. The text objects varying directions (vertical or horizontal)

  4. The text objects should not overlap one another
    (finally, and this one may be the most complex, so might not be the one I do, unless I’m just overthinking this part)

  5. The content of the string array should all be able to fit into and fill the entirety of the display area (size of the display area remains constant)

For a visual explanation of what I’m going for:

collision-detection may work

1 Like

I think what you need to google is packing algorithm, more easy to find rectangle packing or circle packing. Also there is fresh a topic here about circle packing going on…

The idea anyway is to:
.store all stuff drew (rect shapes whatever)
.create next one
.compare all of them to see if they overlap(here comes the collision detection)
.if it serves draw and store
.else try smaller or in different directions, fonts, whatever…
.Collision detection of the bounding box of text is not hard.
.For ‘uneven blobs’ its not trivial.
.There are some libraries that might help.
.It can also be done by testing for colors in a not displayed pGraphics instead of geometrically.

Some hints

1 Like