Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the name of an algorithm that would produce this graphic fill

Tags:

php

graphics

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. Does this algorithm have a name?

http://robertbasic.com/img/sign-letters.gif

like image 452
silow Avatar asked Jan 10 '11 21:01

silow


1 Answers

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:

  1. Are you trying to paint the image as tightly as possible using different sized fonts? (as opposed to all one size of font)
  2. 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
like image 93
brian_d Avatar answered Oct 21 '22 05:10

brian_d