How to check pixels colors
if the rectangle
it only has white return “Incompleto !!”
has white and yellow return “Incompleto !!”
only has yellow return “Amarillos!!”
color a = color(255,255,0);
color b = color(255,255,255);
color r = color(255,0,0);
void setup(){
//Se define el tamaño de la ventana según el tamaño de la imagen
size(750,607);
//rectangulo blanco para pintar
stroke(255);
strokeWeight(1);
fill(b);
rect(200, 260, 200, 200);
}
void draw(){
stroke(10);
strokeWeight(2);
noFill();
if((mouseX>pmouseX)&&(mouseX>200)&&(mouseX<400)&&(mouseY>260)&&(mouseY<460)){
stroke(255, 255,0);
strokeWeight(60);
line(mouseX, mouseY, pmouseX, pmouseY);
}
}
void mousePressed(){
loadPixels();
// Two loops allow us to visit every column (x) and every row (y).
// Loop through every pixel column
for (int x = 200; x < 440; x++ ) {
// Loop through every pixel row
for (int y = 249; y < 320; y++ ) {
// Use the formula to find the 1D location
int loc = x + y * width; // The location in the pixel array is calculated via our formula: 1D pixel location = x + y * width
if (pixels[loc] == a || pixels[loc] == b) { // si los pixeles son amarillos o blancos
textSize(32);
fill(255,0,0);
text("Incompleto!", 270, 300);
// Si tiene el color amarillo
}else if (pixels[loc] == b) {
textSize(32);
fill(255,0,0);
text("Amarillos!!", 270, 450);
}
}
}
}