I'm looking for an algorithm to do this effect, but it's not helping that I don't even know what to look for. I use PHP, so any existing code samples would be great. I want to specify the borders of the shape and have php auto fill it with letters. I'm also open to other ideas to accomplish the same thing. D开发者_开发问答oes this algorithm have a name?
I do not know the exact name of the algorithm - I would imagine that it is a variant of the 2D bin packing problem, but without having the interest of the best possible pack.
Here are some resources and questions:
- Are you trying to paint the image as tightly as possible using different sized fonts? (as opposed to all one size of font)
- Can characters be cutoff at the edges?
If question two is yes, it would seem to me that the easiest way to produce the image would be to fill the entire rectangle with characters, inverse the image shape and use it as a mask.
Here is an answer for not just characters, but entire sentences. Algorithm for Text Wrapping Within a Shape
Edit:
Some popular modern graphic fill websites that could be worthwhile to study
- http://www.tagxedo.com/
really fancy tag cloud shapes - http://www.shapecollage.com/
collages from images into a specific shape
精彩评论