Design practise, Coding 2.

coding 2

During my second workshop on coding I learnt how to make an imagine animate into tiny little squares. To do this this is the code we used.

PImage photo; int imsize; int curplace;

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){ curplace=int(random(imsize)); color thispix=photo.pixels[curplace]; fill(red(thispix),green(thispix),blue(thispix),60); stroke(red(thispix),green(thispix),blue(thispix),60); rect(random(photo.width),random(photo. height), 10,10);

} }

You can see the effect this code had on the image I was working above in the screen shot.


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