Project 4: Oscillation and Random Walk with Perlin Noise

Project 4 of the 2D Generative Design is about generating two images computationally – one using perlin noise and the other using oscillation.

Below is a snippet of code that explains the key concept behind generating the above image on the left using perlin noise:


void perlinMove(PVector inLocation, float inSize, int inRed){
float angle = noise (inLocation.x / noiseScale, inLocation.y / noiseScale) * TWO_PI * noiseStength;
fill(c, 0,0);
ellipse(inLocation.x,inLocation.y, size,size);

The above perlinMove function takes four arguments that determines the location, the size and the amount of red to fill in the circle randomly drawn by the function. Notice how the size and the color of the circles gradually increase until they reach their maximum limit.

Below is a snippet of code that explains the key concept behind generating the above image on the right using oscillation:


void oscillate(){
float cycleCount = (float)frameCount/oscPointCount;
float t = cycleCount % 1;
oscAngle = map(t, 0, 1, 0, TWO_PI);
line(t*oscPointCount, oscPointY, t*oscPointCount, height/2);
}

The oscillate function counts the number of the current frames of the window and divides it by the number of oscillation points used to get a value between 0 and 1. This makes the oscillation dynamic. The sine and cosine function determine the x and y coordinates of the line that is drawn by the function.

Below is a set of few images that show some aspect of how the code was used to generate them:

[huge_it_gallery id=”10″]

The top left image shows the trails of random walks generated by the program after running for about a minute. The top right image shows a complete cycle of oscillation. The image on the bottom shows a half cycle highlighting the trailing sequence of blue lines above it.

The source code of this project can be downloaded from here:
.zip file(2KB)