import processing.core.*; 
import processing.data.*; 
import processing.event.*; 
import processing.opengl.*; 

import java.util.HashMap; 
import java.util.ArrayList; 
import java.io.File; 
import java.io.BufferedReader; 
import java.io.PrintWriter; 
import java.io.InputStream; 
import java.io.OutputStream; 
import java.io.IOException; 

public class brush_smiley extends PApplet {

PImage smiley_1, smiley_2, smiley_3, smiley_4, smiley_5;
PImage current_image;
int counter;

public void setup(){ // Happens only once.
 size(400, 980);
 background(255, 255, 255); // r, g, b
 frameRate(60);
 imageMode(CENTER);
 
 // Loading five images.
smiley_1 = loadImage("1.png");        // 1
smiley_2 = loadImage("2.png");   // 2
smiley_3 = loadImage("3.png");// 3
smiley_4 = loadImage("4.png");//4
smiley_5 = loadImage("5.png");//5
  
 counter = 0;
 current_image = smiley_1;
}

public void draw(){ // Repeats every frame. (60 fps)
  if(mousePressed){ // Is the mouse button being pressed down?
    make_stroke(); // Runs the instructions at the bottom.
  }
}

public void mousePressed(){ 
/*Happens when mouse gets pressed.*/

  switch(counter){
    case 0:
      current_image = smiley_1;
    break;
    
    case 1:
      current_image = smiley_2;
    break;
    
    case 2:
      current_image = smiley_3;
    break;
    
       case 3:
      current_image = smiley_4;
    break;
    
       case 4:
      current_image = smiley_5;
    break;
  }

  counter = counter + 1;
  if(counter > 4){
    counter = 0;
  }
}

public void mouseReleased(){ /* Happens when mouse gets released.*/ }

public void make_stroke(){
  image(current_image, mouseX, mouseY); 
}

/* How to respond to mouse speed.
void make_stroke(){ 
  PVector mousePos = new PVector(mouseX, mouseY); // Vector / Point / Tuple
  PVector pmousePos = new PVector(pmouseX, pmouseY); 
  float distance = mousePos.dist(pmousePos);
  println(distance);
  strokeWeight(distance);
  line(pmouseX, pmouseY, mouseX, mouseY);
}
*/

/* How to respond to mouse position on screen.
void make_stroke(){
  line(pmouseX, pmouseY, mouseX, mouseY);
  float x = mouseX / float(width);
  float y = mouseY / float(height);
  println(x, y);
  stroke(y * 255, 0, 0);
  strokeWeight(x * 10);
}
*/














  static public void main(String[] passedArgs) {
    String[] appletArgs = new String[] { "brush_smiley" };
    if (passedArgs != null) {
      PApplet.main(concat(appletArgs, passedArgs));
    } else {
      PApplet.main(appletArgs);
    }
  }
}
