Perlin Noise

Another important way to simulate randomness is using Perlin noise generation. Perlin noise generation differs from random generation as it uses a “smooth” sequence of psuedo random numbers, where a singular value in a sequence depends on its predecessors. This is especially useful in creating natural phenomena such as clouds and the textures of materials like marble or wood. Take these examples;

Screen Shot 2014-10-10 at 13.12.13 Screen Shot 2014-10-10 at 13.13.18

This example assigns a random brightness to each pixel on the screen. Notice how dark pixels are adjacent to light ones, creating a grainy texture.

Screen Shot 2014-10-10 at 13.07.44 Screen Shot 2014-10-10 at 13.05.50

However this sketch assigns a random brightness to each pixel on the screen using Perlin noise. As the brightness value of each pixel depends on its neighbours, clumps of brightness and darkness form.

Beginning The Nature Of Code

To carry on from the Processing work we did in class, I began to read the book The Nature of Code and start some of the exercises within it. The aim of the book is to teach the reader how to program how to model a digital “ecosystem” using concepts from biology and physics. I chose to look into this book to learn some more advanced programming skills and hopefully I can complete most of the assignements.

To start off the book talks about normal distribution and how in nature variable information usually lies along a bell curve. For example take people’s heights. The height of people can vary greatly, but if you looked at everyone’s heights as a data set, more people would be near the average height than at the two extremes. The mathematics behind this is called Gaussian distribution.

The equations for this are included in the Java library and a version of this is included in Processing. Take for example this code which uses Gaussian distribution to place white dots around a particular point.

gaussiancode gaussian

The lines generator.nextGaussian() creates a Gaussian distribution with ysd and xsd being the standard deviation and xmean and ymean being the mean. The circles are semi transparent so one can see the brighter areas near the middle where more of the dots are clustered, whereas on the outside the dots are more faint as they are less likely to be placed there.

Shiffman, D., 2012. The Nature of Code [online] Mountain View: Creative Commons.

Beginning Work in Processing

The practical part of the first term of our second year is going to be based around the Java-based integrated development environment Processing in order to learn the basics of programming and eventually create a piece of interactive artwork using the program.

In a processing sketch conventionally there are two main functions, void setup, where any “background information” of the sketch (such as setting up arrays) is written and void draw, where functions that provide the output of the sketch are written.  Variables and objects are declared above both these functions. void setup is initialized at the start-up of the sketch whilst void draw is a looping function where the output is drawn at 30 fps.

sketch1code sketch 1 code a sketch1

This sketch draws a line between the point (150, 25) and the mouse. The screen becomes progressively filled with lines as the mouse is moved as a new line is drawn every frame. However on each start-up of the sketch the background color is changed at random.

sketch2code sketch2

However moving the background function to the end of the code provides an output of a sketch with a rapidly changing colored background but no line-mouse output. The background function will overwrite the rest of the sketch.