rvq_Processing/sketch_160813a_10_5_Image_Processing_with_Pixels_ - Cool flashlight effect!/sketch_160813a_10_5_Image_Processing_with_Pixels_.pde
PImage drag; // Initialize a drag variable as PImage

void setup(){
  size(853,480);   // size needs to be EXACT with the image or you get an error
  drag = loadImage("images/drag.jpg");  // Loads an image file from data/images folder
}

void draw(){
  loadPixels(); //loads pixels
  drag.loadPixels();  //loads pixels of the image in question. Is not necessary but should still be used because sometimes it is needed.
  for(int x=0;x<width;x++){ //forloop for X value
     for(int y=0;y<height;y++){
       int loc=x+y*width;
       
       float r=red(drag.pixels[loc]); //Gets red value from drag image and maps it to R
       float g=green(drag.pixels[loc]); // Gets green value from drag and maps it to G
       float b=blue(drag.pixels[loc]); // Gets Blue value from drag and maps it to B
       
       float d=dist(mouseX,mouseY,x,y); // follows mouse movment
       float f=map(d,0,200,2,0);  // Do not completly understand map and what value it will output.
       
       pixels[loc] = color(r*f,g*f,b*f);// multiplies tiwh F (factor)
     }
  }
  updatePixels();
}