Coding
October 30, 2013 § Leave a comment
This session was about using the same coding technique and process on a photo. We chose a passport photo, because it’s simple and sort neutral. The coding in this session will mess with the pixels in this photo, the coding will decide how big the pixels will be and how quick u want them to. Basically what this will do to the pixels is to move them from their original place into a random place within the canvas.
This is the result of the coding for the passport. As you can see it looks pretty abstract, and everything looks a mess
The codes required for this are as follows:
void setup(){
photo=loadImage(“source.jpg”);
size(photo.width,photo.height);
imsize=photo.width*photo.height;
println(imsize);
}
void draw(){
// image(photo,0,0);
for(int lop=0; lop<20; lop=lop+1);{
random(imsize);
curplace=int(random(imsize));
color thispix=photo.pixels[curplace];
fill((thispix),40);
stroke((thispix),40);
rect(random(photo.width),random(photo.height), 10,10)
Next was to add brush strokes onto the photo.
int impos;
float curx;
float cury;
float targx;
float targy;
float brushsize;
void setup(){
face=loadImage(“source.jpg”);
size(face.width,face.height,OPENGL);
curx=random(face.width);
cury=random(face.height);
targx=random(face.width);
targy=random(face.height);
brushsize=5+random(80);
}
void draw(){
fill(0,255,0);
rect(curx,cury,brushsize,brushsize);
fill(255,0,0);
rect(targx,targy,brushsize,brushsize);
curx=curx+((targx-curx)/7);
cury=cury+((targy-cury)/7);
if(targx-curx<5){
//Close in x axis
if(targy-cury<5){
//Close on y axis
// Give new value to strokes
curx=random(face.width);
cury=random(face.height);
targx=random(face.width);
targy=random(face.height);
brushsize=5+random(80);}
}
for(int lop=0;lop<80;lop++){
impos=int(random(face.width*face.height));
color x=face.pixels[impos];
stroke(x,40);
fill(x,40);
int drawy=impos/face.width;
int drawx=impos-(drawy*face.width);
rect(drawx,drawy,10,10);
}
Leave a comment