Coding / Session 2

October 9, 2013 § Leave a comment

[Add and watch video on UniLearn when it’s added, noting down what certain code does]

In today’s coding session we started to apply images to our code. We first obtained a passport image from the internet then saving it into a new folder named ‘data’, saving the file name as ‘source.jpg’, this file is then placed alongside the save file of the code. Below is the code I created, with commentary.

import processing.opengl.*;

PImage face;
  //’PImage’ stands for processing image, this is a datatype for storing images, processing allows for .jpg, .gif, .tga, and .png  images to be displayed

void setup(){
    //’loadimage’ does as it says, finding the saved image of which you must save in the data directory of the current sketch
    //this determines the size of the image

void draw(){
  for(int lop=0;lop<80;lop++){
   // ‘int’ stands for integer, numbers without a decimal point. The first time a variable is written, it must be declared with a statement expressing its datatype.
   // ‘lop’ stands for loop, and the ‘<‘ & ‘>’ symbols mean more & less, while ‘*’ means times
  color x=face.pixels[int(random(face.width*face.height))];

    // the number at the end of this code represents the opacity, in this instance the opacity is reduced to 40%
    // this section of code is what generates the random assortment of rectangles
    // the colours have ‘x’ in place of numbers as it’s reffering back to ‘x=face.pixels’ which makes them the same colours as those found in the image



Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your 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

What’s this?

You are currently reading Coding / Session 2 at Leo Patterson.


%d bloggers like this: