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.
//’PImage’ stands for processing image, this is a datatype for storing images, processing allows for .jpg, .gif, .tga, and .png images to be displayed
//’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
// ‘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
// 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