Mosaic Creator extends Grid Maker

December 31st, 2007 : Nik Rowell

Just as promised, I have a more exciting experiment that makes use of the Grid Maker from my previous post. For those who caught the OOP reference in the title, the Mosaic Creator is actually not a subclass of the Grid Maker… although it probably should be.

After about $15 worth of Vanilla Lattes (which, sadly, is probably only 3), I’m pleased to introduce my Mosaic Creator - and AcionScript 3.0 experiment that dynamically creates a mosaic based on a few variables - photo, tile/cell size etc.

The process is quite similar to that of the Grid Maker, with a few key points:

  1. Create a BitmapData instance to hold the pixel data of the photo.
  2. In each loop through for the rows and columns, create another BitmapData object to hold a sample of the photo the size of our tiles/cells.
  3. Call at getAverageHex(sample:BitmapData) function, with our current sample passed as the argument. This function sums the value of each pixel in our sample and returns the average.
  4. Color the current tile with the average hexadecimal value we just obtained.

And that’s it! Just for fun, I’ve included the explode() function, with a slight variation: I set a random delay for for each cell to be ‘tweened/exploded.

Below is the photo being used to create the Mosaic
(Jon Stenseth in the BWCA, September 2007):

Jon Stenseth in the BWCA, September 2007

View the experiment >

Tags:

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • ThisNext
  • Furl
  • Reddit
  • Slashdot
  • Technorati

Leave a Reply:

Subscribe without commenting