/* Emerson Taymor
Desma 28: Interactivity: Casey Reas
Exercise 11: My idea was to have a high contrast black and white photograph of a doll face.
As you move your mouse over parts of the doll's face different colors are painted in.
She can get rosy cheeks, a rosy nose, a green eye, a blue eye, purple eyebrows, and purple lips.
The images fade in resulting in a faded addition or subtraction of color. It is harsh and a distorted
of the face, while still adding some fun.
*/
//Create an array of images
PImage[] imgs = new PImage[8];
void setup(){
//set the size of the window
size(400,400);
//create a for loop to add images to the array.
for(int i=0; i<imgs.length; i++){
//create a string of the image name
String imgName = new String("img" + i + ".jpg");
//add the image with that name to the proper spot in the array.
imgs[i] =loadImage(imgName);
}
//set this image to be the initial background image
image(imgs[0],0,0);
//set the frame rate to be able to see the fade
frameRate(10);
}
void draw(){
// Create a tint every time draw runs for a fade to be created
tint(255,40);
//if the mouse is in the position around hte eyebrows make the eyebrows purple
if(((mouseX>133) && (mouseX<381)) && ((mouseY>62)&&(mouseY<125))){
image(imgs[4],0,0);
}
//if the mouse is in the position around hte left eye change the eye color
else if(((mouseX>135)&&(mouseX<238))&&((mouseY>120)&&(mouseY<170))){
image(imgs[5],0,0);
}
//if the mouse is in the position of the right eye, change the eye color
else if(((mouseX>297)&&(mouseX<366))&&((mouseY>134)&&(mouseY<192))){
image(imgs[3],0,0);
}
//if the mouse is in the position of the nose, change the nose color
else if(((mouseX>241)&&(mouseX<296))&&((mouseY>144)&&(mouseY<226))){
image(imgs[2],0,0);
}
//if the mouse is in the position of the left cheek, change the cheek color
else if(((mouseX>130)&&(mouseX<236))&&((mouseY>181)&&(mouseY<249))){
image(imgs[7],0,0);
}
//if the mouse is in the position of the right cheek, change the cheek color
else if(((mouseX>302)&&(mouseX<349))&&((mouseY>195)&&(mouseY<281))){
image(imgs[6],0,0);
}
//if the mouse is in the position of the lips, change the lips color
else if(((mouseX>225)&&(mouseX<300))&&((mouseY>253)&&(mouseY<296))){
image(imgs[1],0,0);
}
//if the mouse is not in one of the target areas, play the background image
else{
image(imgs[0],0,0);
}
}
Exercise 11: Load a sequence of images into an array and use the mouse position to control the sequence and time of their display.