fullscreen PImage currentimage;
PImage[] images;
int currentimageindex;
int pointillize = 15;
int prevx;
int prevy;
PFont font;
boolean notstarted;
void setup() {
size(1024,640);
frameRate(120);
images = new PImage[10] ;
images[0]=loadImage("1.jpg");
images[1]=loadImage("2.jpg");
images[2]=loadImage("3.jpg");
images[3]=loadImage("4.jpg");
images[4]=loadImage("5.jpg");
images[5]=loadImage("6.jpg");
images[6]=loadImage("7.jpg");
images[7]=loadImage("8.jpg");
images[8]=loadImage("9.jpg");
images[9]=loadImage("10.jpg");
int ran = (int)(double)((Math.random()*100)%8); //assigns a random image
currentimage = images[ran];
loadPixels();
currentimageindex=0;
background(0);
prevx=0;
prevy=0;
smooth();
font = loadFont("DaunPenh-28.vlw");
textFont(font,80);
fill(256,256,256,80);
textAlign(CENTER);
text("VAN GOGH IN THE RAIN",width/2,height/2);
textFont(font,25);
text("created by Ritvik Menon", width/2,height/2+30);
fill(256,256,256,80);
textFont(font,20);
text("Developed in Processing", width/2,height/2+60);
text("Click to load a painting - Click again to load a different one", width/2,height- 15);
notstarted = true;
}
void draw() {
if (mousePressed){
if(notstarted ==false){
fill(256,256,256,40);
textFont(font);
textAlign(CENTER);
text("VAN GOGH IN THE RAIN",width/2,40);
textFont(font,20);
text("created by Ritvik Menon", width/2,55);
}
fill(256,256,256,50);
text("Wait 20 seconds for the painting to appear Click again to load a new painting ", width/2,height- 15);
notstarted = false;
nextimage();
}
if (notstarted == true)
return;
drawcommands();
}
void drawcommands(){
//detail
for (int i =0; i<10 ; i++){
drawcircle(i+2,100-i*5);
drawcircle(1,100);
drawcircle(2,70);
drawcircle(2,100);
drawcircle(2,100);
drawcircle(2,100);
drawcircle(3,80);
drawcircle(3,50);
drawcircle(5,50);
}
//blurry ones
drawdarkcircle(20,15);
drawdarkcircle(50,15);
drawdarkcircle(100,10);
drawdarkcircle(200,8);
}
void drawmousecircle(){
int x = (int) ( mouseX + random(10));
int y =(int) ( mouseY + random(10));
int loc2 = x + y*currentimage.width;
float r2 = red(currentimage.pixels[loc2]);
float g2 = green(currentimage.pixels[loc2]);
float b2 = blue(currentimage.pixels[loc2]);
noStroke();
fill(r2,g2,b2,70);
//stroke(r2,g2,b2,30);
int ran = (int)random(100);
ellipse(x,y,5,5);
// line(x*4,y*4,mouseX,mouseY);
}
void drawdarkcircle(int rad, int alph){
// Pick a random point
int x2 = int(random(currentimage.width));
int y2 = int(random(currentimage.height));
int loc2 = x2 + y2*currentimage.width;
// Look up the RGB color in the source image
int darkfactor =+50;
float r2 = red(currentimage.pixels[loc2])-darkfactor;
float g2 = green(currentimage.pixels[loc2])-darkfactor;
float b2 = blue(currentimage.pixels[loc2])-darkfactor;
noStroke();
// Draw an ellipse at that location with that color
fill(r2,g2,b2,alph);
ellipse(x2,y2,rad,rad);
stroke(r2,g2,b2,5);
}
void drawcircle(int rad, int alph) {
// Pick a random point
int x2 = int(random(currentimage.width));
int y2 = int(random(currentimage.height));
int loc2 = x2 + y2*currentimage.width;
// Look up the RGB color in the source image
float r2 = red(currentimage.pixels[loc2]);
float g2 = green(currentimage.pixels[loc2]);
float b2 = blue(currentimage.pixels[loc2]);
noStroke();
// Draw an ellipse at that location with that color
fill(r2,g2,b2,alph);
ellipse(x2,y2,rad,rad);
// stroke(r2,g2,b2,5);
//line(x2,y2,prevx,prevy);
//prevx=x2;
//prevy=y2;
//noStroke();
}
void nextimage(){
int ran2 = (int)(random(9)); //assigns a random image
currentimage = images[ran2];
loadPixels();
}
Van Gogh in the Rain - pontillize effect with different shaped circles to give an impression over rain over the images
Click again to change the painting being generated.
Works MUCH smoother for me when ported through HTML5 (as in the link below) for some reason. The linked version also has sound:
http://www.ritvikmenon.com/compsci/vg/vangoghintherain.html