I started playing around with a random grid project the other week when I came across a desktop I really like that is comprised of a grid of randomly placed blocks with an image built into the grid made of lighter blocks. The desktop is over at Vlad Studios, and is still one of my favorites, but the grid generator I have been building has gone a bit further than just building a grid of 10 pixels blocks.
I started pretty small, and just tried to build a 100 x 400 pixel grid, and have it timed to see the build. First, I tried using setInterval, but it turned out to be way too slow and pulled too hard on the CPU, so I went back to a good ol' frame loop. It took me a little bit to get back to filling in all of the spots, and then figuring how to complete the grid randomly without duplicating any of the positions. After that I started playing with colors, and randomly creating a variation in the block color at the same time.
I think it's pretty cool and you can check it out here.
I am trying to get beyond just duplicating the desktop and into something that can produce a pattern that is both interesting and unique. Where I want to take it next is two-fold. I want to create another function or set of functions to create an additional pattern on top of the grid, that would ultimately be a shape translated into a grid form or just an outline. The shape would be randomly selected from a set of shapes within the library. Then after that I would like to port the whole to AS3 rather than AS2 what it is now.
Something else I would like to do is add a Perlin Noise filter to it that would dictate the pattern of the color shift of the grid as it is being built, but that would be after I get it written in AS3, which I have no idea how to do just yet….
Any way, if you are interested you can download the FLA file.
As a side note, the forums and folks over at ActionScript.org have been a great help.