Code

Example Code

To see some examples on how to use the CellNoise library in your Processing program, download the example file. Therein is all the code for the patterns in the gallery. The animations are also interesting for animating the patterns.

All examples are based on the same thing though. First you include the library in your code:

import CellNoise.*;

To be able to work with animation or just space-varying patterns, it's appropriate to create a position array, at, with 2 or 3 values. This is passed to CellDataStruct at its instantiation, and used later as a working array in the loop.

double[] at = {0, 0, 0};

Then create a CellDataStruct and initiate it with the number of feature points to search, the position variable and a distance measure type:

CellDataStruct cd;

cd = new CellDataStruct(this, 3, at, cn.EUCLIDEAN);

Also create a CellNoise. No properties has to be set here. All noise properties are set through the CellDataStruct. This makes it possible to use several different character noises by creating multiple CellDataStructs together with only one CellNoise.

CellNoise cn;

cn = new CellNoise(this);

At last there is the final animation. This example below plots the plane at the given position in the 3rd dimension. As time goes, the plane moves in the 3rd dimension, but stays the same in 1st and 2nd. Notice the frequency used in the three dimensions.

at[2] += 0.07;

for (x = 0; x < width; x++) {

at[0] = 0.05 * ( x + 20);

for (y = 0; y < height; y++) {

at[1] = 0.04 * ( y + 700 );

cd.at = at;

cn.noise(cd);

set(x, y, color(cd.F[0]*150));

}

}

This code represents one of the most simple implementations of the cell noise library, and should be inserted into the draw() function of a Processing program.

If these explanations together with the examples in the gallery aren't enough, feel free to spontaneously contact me about it. I'll try to help out!

log in administrator | design: c & s