Hi, I’m not very good at processing and am stuck with this code.
I drew 5 squares with the color of the x and y position of the mouse. Next, I want to state that with the first mouseclick the color the mouse is on at that moment will be fixed in the first square. and the second click has to fill the second square with the color of the mouse position. Anyone have any clue how to do this? thank so much in advance!
PImage salad;
import processing.pdf.*;
boolean record;
void setup(){
size(875, 875);
noStroke();
salad = loadImage("salad.jpg");
}
void draw() {
if(record){
beginRecord(PDF, "frame-####.pdf");
}
image(salad, 0,0);
color a = get (mouseX, mouseY);
color b = get (mouseX, mouseY);
color c = get (mouseX, mouseY);
color d = get (mouseX, mouseY);
color e = get (mouseX, mouseY);
fill(a);
rect(100,100,100,100);
fill(b);
rect(100,250,100,100);
fill(c);
rect(100,400,100,100);
fill(d);
rect(100,550,100,100);
fill(e);
rect(100,700,100,100);
if(record){
endRecord();
record = false;
}
}
void mouseClicked() { //I want the square filled in with the color my mouse is on at that time
}
void keyPressed() { //if you press enter the frame gets saved as a pdf
record = true;
}
Thank you so much for your help this is really nice. but I’m wondering do I have to call the different rectangles on the dots after a = … ?
because then the rect’s should have different names or not? idk how to change that.
Aaah right! that was the mistake, still had the colors in draw…
that’s amazing thank you!
do you think there is a possibility to still see the colors in the squares when the mouse is hovering over the image, before the click. so you can realy select a color?