cluster 3cluster 1

cluster 4cluster 2

I’ve been doing some experimenting with another method to create generative graphics. Rather than using a straightforward iterated function system, these images were created with a basic particle system. in this case the only factors effecting the particles are attraction and repulsion between all of the particles to all other particles within a certain range.

Each image is rendered with slightly different methods, using some combination of dots at the particle location, a line from each particle to its previous location, and lines between particles effecting each other. In the script I created I can toggle whether or not the pixel buffer is being cleared or not. The parameters determining the forces between the particles and the range of their effect are determined by the mouse position. Changing these variables in different ways can create a surprising number of different images because the structure is not only determined by the current settings but is often also changed by the previous ones.

To control whether the pixel buffer is being cleared or not, essentially whether it is drawing continuously or only rendering the current frame set a global boolean variable. Something like boolean d=true;at the very beginning of the script. Then add a script to draw a background if the variable is false (or true).

if (d==true) {
  background(255);
}

That script needs to be within the draw function. Then, to allow the variable to be toggled, add some conditional logic to an input function like the mouse or keyboard.

void mousePressed() {
  if (d==true) {
    d=false;
  } else {
    d=true;
  }
}

This function needs to be at the top level of the script, not contained within anything else. But can otherwise go in anywhere else. I usually put all my input functions in a separate tabs to keep everything neat.

Another useful snippet will save the current frame.

void keyPressed() {
  if (key=='s'){
    saveFrame("filename-####.png");
  }
}

Again this could be called on any other input, for most of my scripts I use the ‘s’ key just to be consistent. “filename” can be changed to whatever you like as can the extension, but remember it is limited to “.tif”, “.tga”, “.jpg”, or “.png”. an invalid extension will just be added as part of the filename and the image will be saved as a “.tif.

The particle system can be built a number of different ways. The essential structure is an array of objects with a function to render the particle and a function to determine the motion of each. This could be a physically accurate model, but for many applications, particularly a drawing system, accurately reflecting physical motion is much more involved to code and render than is necessary.