Algorithms – Processing Practice

Standard

Learning Processing is no easy task – unless you are force to, by it being a part of your University class, so while I continue to look at how processing uses algorithms to produce anything – let us have a look at some example of how repetition and variations are produced from processing, jumping straight into it seems to be the way to do it (well it’s the way I get told).

The following code is for a multiple random, coloured, Pikachu Picture:

//declare image object
PImage img;
// set up
void setup () {
// canvas size
size(500, 600);
background(255);
// Make a new instance of a PImage by loading an image file
img = loadImage (“/Users/jb523/Desktop/Pikachu.jpg”);
}

void draw () {
// Draw the image to the screen at coordinate (0,0)
for (int row = 0 ; row < 5 ; row = row + 1) {
for (int count = 0 ; count < 5 ; count = count + 1) {
tint(random(255), random(255), random(255));
image(img, count*100,row*120, 100, 120);
}
}
}

The indication of the line that starts with ‘tint’ indicates a random colour to each individual picture as well as changing the colour rapidly – below are 3 screenshots that show the change in colour – using only the process above:

Pikachu Random(255)

Each line represents a piece of information that tells the computer what to do – the lines are broken into a command and a function. If we just change the code we can change the appearance of how we want something to look.

What if we wanted a gradual change from black to anything, going from the top left to the bottom right using colour as a transition, we would get:

Pikachu Random(count x row x 51)The only change made was in the “tint” command, instead of random colours per each picture we made the process start at black and multiple by a number to get another colour.

Continuing the change of the “tint” we can make the tint all one colour, shown:

Pikachu background change
We can even change the columns to individual colours while using grey-scale to get to white.

Pikachu shade black to whiteWhile I find Processing difficult, the creations – even if nothing useful are still interesting. This isn’t my strong point, though I enjoy doing it and exploring what processes I can explore and the things I create.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s