The poor man's DLA (Diffusion Limited Aggregation)

A result of poor man's Diffusion-limited aggregation.

Creative coding work made with Processing.

How and why I made this program?

Creative coding with DLA in the beginning.

I tried to write a code about DLA(Diffusion-limited aggregation).

As you know, DLA needs Brownian motion. This time, I did not implement Brownian motion but a simple random walk.

Reference. 知識のサラダボウル | 拡散律速凝集

A random walk through top to bottom.

I drew the path of the random walk. It looks like thunder.


Flash of inspiration.

Then, I thought suddenly 'It probably does not need a random walk?'. So, I tried to shoot a cell on a straight line from a random angle.

Still more, I can drop a cell straight down from a random position.


What I need is randomness.

In the same way, I can shoot a cell on a straight line from a random angle to the center of the canvas.

I can shoot a cell slightly shift from the center on the way.

These look like a real DLA result. But I do not use Brownian motion, so I think they'll not call it a DLA.


Complete regularity?

Then, what happens when I shoot a cell regularity not randomly?

When I do it ordinarily.

When I tune the rhythm.


Here is the economical DLA code made with 'Processing' (Java).

And furthermore, I can draw with a complex rhythm like this.

Finally, I made such a complex shape with regularly rhythm shooting, with no random.


Here is the example code of the poor man's DLA.

This code does not display any images on the screen but generates image files in frames directory. You can make an animation with these files.

Please feel free to use this code under the terms of the GPL.
To see other works based on my code is my pleasure. And my honor.

 * Poor man's DLA
 * @author @deconbatch
 * @version 0.1
 * Processing 3.2.1
 * created 2019.10.01

 * Point : Hold a point information.
private class Point {
  public float x, y, h; // informations are writable purposely

   * @param  _x   : x-coordinate value of the point.
   * @param  _y   : y-coordinate value of the point.
   * @param  _hue : hue value of the point.
  Point(float _x, float _y, float _hue) {
    x = _x;
    y = _y;
    h = _hue % 360.0;

void setup(){
  size(720, 720);
  colorMode(HSB, 360.0, 100.0, 100.0, 100.0);
void draw(){

  int   plotMax = 7200;
  int   frmMax  = 24 * 1;
  int   walkMax = height * 2;
  float pSize   = 4.0;
  float pHue    = random(360.0);
  float initDiv = random(0.1, 0.4);

  ArrayList<Point> cluster = new ArrayList<Point>();

  for (float i = 0.0; i < 1.0; i += initDiv) {
    cluster.add(new Point(
                          0.2 * width * cos(TWO_PI * i),
                          0.2 * height * sin(TWO_PI * i),

  translate(width * 0.5, height * 0.5);

  float entryR = 1.0;  // entryRadius
  for (int plotCnt = 0; plotCnt < plotMax; plotCnt++) {

    // complex rhythm
    entryR += entryR;
    entryR = entryR % TWO_PI;
    Point p = new Point(
                        width * cos(entryR),
                        height * sin(entryR),
    for (int walkCnt = 0; walkCnt < walkMax; walkCnt++) {

      // walk to the center
      p.x -= cos(entryR);
      p.y -= sin(entryR);
      if (checkCollision(cluster, p, pSize)) {
        pHue += 0.015;

    if (plotCnt % floor(plotMax / frmMax) == 0) {
      background(0.0, 0.0, 90.0, 100.0);
      drawCluster(cluster, pSize);
      saveFrame("frames/0." + String.format("%05d", plotCnt) + ".png");


  // draw the final frame
  background(0.0, 0.0, 90.0, 100.0);
  drawCluster(cluster, pSize);


 * drawCluster : draw the points cluster 
 * @param  _cluster : ArrayList of the Point class.
 * @param  _size    : draw point size.
private void drawCluster(ArrayList<Point> _cluster, float _size) {
  float eSat = 40.0;
  float eBri = 60.0;
  for (Point p : _cluster) {
    eSat += 0.009;
    eBri -= 0.003;

    fill(p.h, eSat, eBri, 100.0);
    ellipse(p.x, p.y, _size, _size);

 * checkCollision : check collision between a point and the cluster.
 * @return boolean  : true = detect collision.
 * @param  _cluster : ArrayList of the Point class.
 * @param  _p       : a point
 * @param  _size    : size of the point.
private boolean checkCollision(ArrayList<Point> _cluster, Point _p, float _size) {
  for (Point p : _cluster) {
    if (dist(p.x, p.y, _p.x, _p.y) < _size * 1.0) {
      return false;

  for (Point p : _cluster) {
    if (dist(p.x, p.y, _p.x, _p.y) < _size * 1.2) {
      return true;
  return false;

Copyright (C) 2019- deconbatch

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <>


Example results.

Processing code examples above made this image.
You can make this with Processing code examples here.
Please see Processing code examples in this article.


Next Post Previous Post
  • Unknown
    Unknown Wednesday, April 15, 2020

    I'm absolutely blown away by this! I intend to use this very soon, and I'll be sure to tag you when I do. I'm always so grateful for people like yourself that share your knowledge in an accessible way.

    One note: when I copied this into Processing, I had to slightly modify the argument declarations. Everywhere that you have `ArrayList _cluster`, I had to change to `ArrayList<Point> _cluster` for it to compile. I'm using Processing 3.5.4, so slightly different version, just wanted to let you (and any future readers) know

    • deconbatch
      deconbatch Thursday, April 16, 2020

      Thank you for pointing out! I appreciate it!🙂
      It was my mistake and I fixed it now. This time I copied code from this article and ran it for confirmation.👍

Add Comment
comment url