This seems like a pretty easy thing to do, but I've never done anything like it and I would rather not reinvent the wheel - so I'm looking for example code in pretty much any language or an algorithm that explains how this is done. If not that a pointer to what I should actually be searching for (computer science theories/Branches that cover this kind of thing) would be appreciated.

Assuming I have a bunch of dark and light common household items, these could be anything really - Teddy Bears, Dominoes, cupcakes whatever laid out in a grid where each cell is a single one of these objects. Obviously when you look at the objects in the grid you can see the details of the object, that is to say you can recognize it is a Teddy Bear if it is a Teddy Bear. I want an algorithm, or code examples in whatever language that shows me how to take the Darker objects and arrange them to spell out words. As a very primitive example of what I mean look at this image https://c8.alamy.com/comp/AX3KY0/red-chili-peppers-spell-out-words-relating-to-their-taste-AX3KY0.jpg where chili peppers have been arranged to spell the word hot. Obviously this is not an exact example of what I want because this takes advantage of the shape of the chili to make the individual strokes of the letters and I expect instead to have the objects the code arranges to be more structured.

So if the letter H where spelled out in Teddy Bears I suppose the H would take 12 cells to draw, the left most vertical stroke of the H to be composed of 3 Dark Teddy Bears, the middle of the H composed of 2 light Teddy Bears above the middle horizontal stroke, the middle horizontal stroke 2 Dark Teddy Bears, and the lower of the middle two Light Teddy Bears again, and then the rightmost vertical stroke would again be 3 Dark Teddy Bears. This way one does not need to do anything clever like rotate the Teddy Bear to make the middle lines.

if i were to assume how such an algorithm would work I would think I have every position in the grid given a number, then every alphanumerical character I want to support having a corresponding Object that describes how the item is positioned to make the strokes of the character. I have the length of the text I want to write I determine if it can be written in the grid and where I have to start to write it, (how?) then I look up first letter T and get move commands do it, move 1 column over get next letter h and do move commands. But that is my probably reinventing the wheel and as you can see I still would need to work out quite a bit more to be able to actually make it work.

Other examples of people spelling things with common items - https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT7F-liVWnR7P8tzAVqJfg7fJPoTDN1sroNYr9gi67XfNj7wSkw (has profanity)


These are not exactly what I want as they assume an even background whereas I want the words I spell out of everyday items to be mixed in with lighter versions of that item.

I tried to make this question before but it was not understood, hopefully I have been precise and verbose enough that what I'm looking for is understandable.

  • $\begingroup$ I don't know an algorithm that does exactly what you want, although I'm pretty sure someone has done this before. But reinventing the wheel shouldn't be too much work in this case. With your approach you'll run into problems with characters that contain lines that are not horizontal or vertical like A, B, C, D, G, ... if your grid is too coarse. A random filling of the characters and the background could solve this problem. (See e.g. paulbourke.net/fractals/randomtile to get an idea of what I mean. All of the objects could be of the same size.) $\endgroup$ – Chris Apr 20 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.