Avatar Part 2

Posted on: July 4th, 2016 by Peter Balazs No Comments

How could we improve on the randomly generated avatar from last week? Well actually there probably is a bunch of ways, but this week I’ll look at just one (don’t worry, no avatars next week). Which is… making it half random of course 🙂
But seriously… The last avatar had totally random patterns, which didn’t generate cool patterns most of the time. Most of them looked like a very confused snake game. This time we’ll make only half of the avatar random, and mirror the pattern we get.
Here’s the demo:

The main avatar area is divided into two parts. An upper and a lower part. The upper part is filled with randomly filled divs, which are saved in an array as they are generated. The divs are floated left. When this is done the array gets reversed, the divs are placed in the lower part floated right. In the end the main avatar area is rotated 90 degrees. And that’s it. We have a much cooler looking avatar.

Leave a Reply