---
title: "Processing: DLA, quadtrees"
date: "2010-07-04"
author: Chris Hodapp
tags:
- processing
---

I first dabbled with
[Diffusion-Limited Aggregation](http://en.wikipedia.org/wiki/Diffusion-limited_aggregation)
algorithms some 5 years back when I read about them in a book (later
note: that book was
[Nexus: Small Worlds and the Groundbreaking Theory of Networks](http://www.amazon.com/Nexus-Worlds-Groundbreaking-Science-Networks/dp/0393324427?ie=UTF8&*Version*=1&*entries*=0)). The
version I wrote was monumentally slow because it was a crappy
implementation in a slow language for heavy computations
(i.e. Python), but it worked well enough to create some good results
like this:

<!--  TODO: Originally:
[![Don't ask for the source code to this](../images/dla2c.png){width=50%}](../images/dla2c.png)\ 
-->
{{< figure resources="dla2c.png" title="Diffusion Limited Aggregation" caption="Don't ask for the source code to this">}}

After about 3 or 4 failed attempts to optimize this program to not
take days to generate images, I finally rewrote it reasonably
successfully in [Processing](http://processing.org/) which I've taken
a great liking to recently. I say "reasonably successfully" because it
still has some bugs and because I can't seem to tune it to produce
lightning-like images like this one, just much more dense
ones. Annoyingly, I did not keep any notes about how I made this
image, so I have only a vague idea. It was from the summer of 2005 in
which I coded eleventy billion really cool little generative art
programs, but took very sparse notes about how I made them.

It was only a few hours of coding total. Part of why I like Processing
is the triviality of adding interactivity to something, which I did
repeatedly in order to test that the various building-blocks of the
DLA implementation were working properly.

The actual DLA applet is at
[http://openprocessing.org/visuals/?visualID=10799](http://openprocessing.org/visuals/?visualID=10799). Click
around inside it; right-click to reset it. The various building blocks
that were put together to make this are:
[here](http://openprocessing.org/visuals/?visualID=10794),
[here](http://openprocessing.org/visuals/?visualID=10795),
[here](http://openprocessing.org/visuals/?visualID=10796),
[here](http://openprocessing.org/visuals/?visualID=10797), and
[here](http://openprocessing.org/visuals/?visualID=10798).

These are at OpenProcessing mostly because I don't know how to embed a
Processing applet in Wordpress; perhaps it's better that I don't,
since this one is a CPU hog.  (*Later note:* I wonder if I can just
host these examples inline using
[Processing.js](http://processingjs.org/)...)

This blog also has an entire gallery of generative art with Processing
that I think is great:
[http://myecurve.wordpress.com/](http://myecurve.wordpress.com/)
