A few people have expressed interest in how Wavatars are made. Here is the long boring explanation for those overly curious souls. Again, if you want the WordPress plugin, go for it. If you want to adapt it for non-Wordpress use, help yourself.
All of the following is done in PHP: This isn’t exacly the most complex process in the world. Pretty simple, but the results are amusing to me.
Step 1 is to generate an 80×80 blank PNG using
imagecreatetruecolor (). That image is then flood filled a color of a random hue (max saturation, low lightness value) with
Step 2 selects a random “fade” pattern from a possible 4. This is a simple white PNG with a gradient mask that will cause the background to fade from that base color to white. This makes the icon a little more interesting, and adds some variety.
Step 3 selects a random face shape from the possible 9. It loads in the mask of the chosen face and slaps it into place. I have a black border on the mask, because that looks nice.
Step 4 selects a color for the head. Again, this is a random hue, max saturation, high lightness value. It then flood fills the image starting in the very center at 40, 40. Note that this creates an interesting limitation. The face has to be a single enclosed polygon that covers the center. This means you couldn’t make a head from two shapes which weren’t touching, and you couldn’t make a shape with a hole right in the middle
I could get around these limits by using
imagefilter (IMG_FILTER_COLORIZE) instead of
imagefill (), but I found that not all setups of PHP will support this, and that if it fails the wavatar will come out white. I figured portable, functional code was more important than something which would silently fail in confusing and unrecoverable ways for some users.
For each mask shape, (circle, triangle, square, etc) I have a matching “shine” filter. This is another gradient-masked PNG of pure white, which is used to make the shape look glossy. It’s totally opaque in the areas with lots of shine, low transparency accross the main surface, and fully transparent where the “shadows” should be. I made these using the “emboss” tool in Paint Shop Pro 8.
Step 5 puts this shine image into place. Note that this step is optional. (You’ll need to have the know-how to edit the source if you want to skip it, though.) If you skip it, the Wavatars will look a little more cartoony and a little less like they’re made of iPod plastic.
Step 6 selects a random set of eyebrows and slaps them on. No fancy filters or coloring this time. The brows go on before the other features so that they will appear “behind” eyeglasses.
Step 7 selects a random set of empty eyes / eyeglasses and slaps them into place.
Step 8 selects a set of pupils and adds them.
Step 9 adds the mouth.
The last step is to resample the image from the default size to the icon size the user selected (assuming they differ) and save the resulting image to disk.
That’s it. All done. You could, if you wanted, add all kinds of additional shapes to any of the categories, or replace ones you don’t like. If you change the number of available images, you’ll have to edit the source code so that the plugin knows how many images are available. Don’t worry – you can do this even if you don’t know PHP. Just look inside of wavatars.php and near the top you’ll see a few lines:
Just change the number in quotes to reflect the number of images you’re using, and you’re all done. You can modfy Wavatars just a bit, or replace them with something totally different.
Game at the Bottom
Why spend millions on visuals that are just a distraction from the REAL game of hotbar-watching?
A look at the main Borderlands games. What works, what doesn't, and where the series can go from here.
Silent Hill 2 Plot Analysis
A long-form analysis on one of the greatest horror games ever made.
Good Robot Dev Blog
An ongoing series where I work on making a 2D action game from scratch.
Grand Theft Railroad
Grand Theft Auto is a lousy, cheating jerk of a game.