int currentScreen;
PImage img;
PImage img0;
PImage img1;
PImage img2;
PImage img3;
import processing.sound.*;
SoundFile file, file2;
void setup() {
size (1000, 683);
//noStroke();
img = loadImage ("batman.jpeg");
img0 = loadImage ("joker.jpg");
img0.resize(1000, 683);
img1 = loadImage("jolaugh.jpg");
img1.resize(1000, 683);
img2 = loadImage("riddler.jpeg");
img2.resize(1000, 683);
img3 = loadImage("rid.png");
img3.resize(200,300);
file = new SoundFile(this, "jlaugh.mp3");
file2 = new SoundFile(this, "rmt.mp3");
}
void draw() {
switch (currentScreen) {
case 1:
keyPressedOne();
break;
case 2:
keyReleasedOne();
break;
case 3:
keyReleasedTwo();
break;
default:
image(img, 0, 0);
break;
}
fill(255);
text(currentScreen, width-23, 23);
}
void mousePressed() {
currentScreen++;
if (currentScreen > 4) {
currentScreen = 0;
}
}
void keyPressedOne() {
if (keyPressed) {
if (key == 'a') {
int x = int(random(img.width));
int y = int(random(img.height));
color pix = img.get(x, y);
fill(pix, 128);
ellipse(x, y, 50, 50);
}
} else {
background (200);
}
}
void keyReleasedOne() {
if (keyPressed) {
if (key == '1') {
img1.loadPixels();
for (int x = 0; x < img1.width; x++ ) {
for (int y = 0; y < img1.height; y++ ) {
int loc = x + y*img1.width;
float r = red (img1.pixels[loc]);
float g = green(img1.pixels[loc]);
float b = blue (img1.pixels[loc]);
//float adjustBrightness = map(mouseX, 0, width, 0, 8);
////r *= adjustBrightness;
////g *= adjustBrightness;
////b *= adjustBrightness;
color c = color(r, g, b);
if (y > mouseY)
c = color(200, random(60,100), r, 0);
if (x > mouseX/2)
c = color(random(0,150),b, 50, 0);
if (x > mouseX)
c = color(r/2+62, b*1.5, g/2+50, 0);
r = constrain(r, 0, 255);
g = constrain(g, 0, 255);
b = constrain(b, 0, 255);
//noStroke();
//fill(c);
//ellipse(x,y,10,10);
img1.pixels[loc] = c;
}
}//for
img1.updatePixels();
image(img1, 0, 0);
}
if(!file.isPlaying()){
file.play();
}
} else {
img0.resize(1000, 683);
image(img0, 0, 0);
}
}
void keyReleasedTwo() {
if (keyPressed){
if ( key == '2') {
background(img2);
//blend(img3, 0, 0, 33, 100, 67, 0, 33, 100, ADD);
//blend(img3, 0, 0, 33, 100, 67, 0, 33, 100, ADD);
int i = 1;
while (i < 100) {
image(img3, i*10, i*5);
i = i + 20;
}
if(!file2.isPlaying()){
file2.play();
}
}
} else {
image(img2, 0, 0);
}
}
NEED HELP WITH ‘IMG1’ PIXEL DISPLAY