processing. pie pack illustrations I've been working on a massive project at work lately and one tiny portion of it was creating visuals for analytics. In addition I've been exploring circle packing and rigid body physics engines (i.e. Box2d and Chipmunk) in Adobe Illustrator with scriptographer (ridiculous I know) and paper.js (more acceptable). Once I have more time I'll publish my results on these explorations.
In my pseudo-delirium and boredom of working with these info graphics, I wondered if illustrations made from circle packed pie charts would be remotely interesting. Turns out the answer is "Jein"
Since I was already exploring circle packing it seemed logical to pack the charts together. At first I began sketching in scriptographer, but it quickly became obvious I would need/want a little more power under the hood to generate the charts, however, now I have a nice little script to pack objects (circles) in illustrator (yes... ridiculous I know).
Using processing the sketch loads an image on start-up and maps brightness areas using a voronoi mesh which I conveniently borrowed from EVIL's SVG Stipple Generator. The size of voronoi areas match to the brightness (0 smaller, 255 larger) of the area in the image over which it lies, which is then mapped to the size of the created pie chart as well as the number of pieces to show in the chart.
The charts are pretty straight forward in their construction. Size as mentioned above is based on brightness value and mapped to a minimum and maximum size as set from the GUI, the number of pieces is determined by brightness and mapped to a max number of pieces count, hole and hole size can also be controlled via the GUI.
Sprinkle in some methods to output to PDF and TIFF and presto chango. After playing with the app for a bit, I was thinking "ok... now what?" PDF's and TIFF's are nice on screens, but... what if I could screen print (or whatever) some of these. I would need to limit the number of colors used, posterize. boom. done. right? Yes, but boring, so I whipped up a threaded class that recolors the source image based on the colors from another image, so now I can limit colors to the number I choose as well as choose the exact colors I want. And then for shits and giggles I added Kuler support to pull in color palettes.
This was a nice short little experiment that I'm happy with. It was satisfying to sketch out the idea and follow through with very little resistance along the way (as opposed to some of my recent forays into physical computing).
This is the class for recoloring images, it's threaded so that when used in conjunction with the rest of an app it won't interfere with the framerate.
And here's the class which wraps some direct opengl calls for drawing the pie (charts), I've noticed you can get upwards of 500 or so charts before the app starts to get bogged down.
Code for the voronoi brightness mapping you can get that from the StippleGen source code StippleGen.zip. Lastly the code for circle packing was modified from Iain Maxwell's cell packing code. There are some odd behaviours of the code as you can see in the above video, i.e. when lots of circles are added they begin to overlap, at some point I will investigate further.
For the Kuler support, I've updaded my frederickk processing library with an FKuler class (which is a cleaner implementation of what I used here).
The most recent build of the library can be downloaded here