Buttons not interacting properly
in
Programming Questions
•
1 year ago
I have 7 buttons for an RGB colour corrector, an individual + and - for each R, G, and B and then a reset button.
However when I hover over the Blue - button it also highlights the RESET button and it acts as if it is being pressed, in terms of increasing the strokeWeight but it does not reset everything. That only happens when I click the reset button. However I obviously would like to get rid of the fact that when I interact with the Blue - button, the RESET button acts as if it is being interacted with.
Any help would be appreciated, thank you!
- PImage Mushrooms;
- PImage Mushrooms2;
- float redCC = 1;
- float greenCC = 1;
- float blueCC = 1;
- void setup() {
- Mushrooms = loadImage ("Mushrooms.jpg");
- int dimension = (Mushrooms.width*Mushrooms.height);
- Mushrooms2 = createImage(Mushrooms.width, Mushrooms.height, RGB);
- size(Mushrooms.width*2, Mushrooms.height);
- smooth();
- }
- void draw() {
- Mushrooms = loadImage ("Mushrooms.jpg");
- int dimension = (Mushrooms.width*Mushrooms.height);
- Mushrooms2 = createImage(Mushrooms.width, Mushrooms.height, RGB);
- Mushrooms.loadPixels();
- Mushrooms2.loadPixels();
- for (int i=0; i < dimension; i+=1) {
- Mushrooms2.pixels[i] = color( red(Mushrooms.pixels[i])*redCC, green(Mushrooms.pixels[i])*greenCC, blue(Mushrooms.pixels[i])*blueCC);
- }
- Mushrooms2.updatePixels();
- image(Mushrooms, 0, 0);
- image(Mushrooms2, 1024, 0);
- //POSITIVE RED
- if (dist(Mushrooms.width/4, 640, mouseX, mouseY) < 50 / 2) {
- stroke(0);
- if (mousePressed) {
- strokeWeight(5);
- redCC = redCC+0.2;
- }
- }
- else {
- cursor(ARROW);
- noStroke();
- strokeWeight(1);
- }
- rectMode(CENTER);
- fill(255, 0, 0);
- rect(Mushrooms.width/4, 640, 50, 50);
- fill(0);
- rect(Mushrooms.width/4, 640, 30, 8);
- rect(Mushrooms.width/4, 640, 8, 30);
- //NEGATIVE RED
- if (dist(Mushrooms.width/4, 700, mouseX, mouseY) < 50 / 2) {
- stroke(0);
- if (mousePressed) {
- strokeWeight(5);
- redCC = redCC -0.2;
- }
- }
- else {
- cursor(ARROW);
- noStroke();
- strokeWeight(1);
- }
- fill(255, 0, 0);
- rect(Mushrooms.width/4, 700, 50, 50);
- fill(0);
- rect(Mushrooms.width/4, 700, 30, 8);
- //POSITIVE GREEN
- if (dist(Mushrooms.width/2, 640, mouseX, mouseY) < 50 / 2) {
- stroke(0);
- if (mousePressed) {
- strokeWeight(5);
- greenCC = greenCC+0.2;
- }
- }
- else {
- cursor(ARROW);
- noStroke();
- strokeWeight(1);
- }
- rectMode(CENTER);
- fill(0, 255, 0);
- rect(Mushrooms.width/2, 640, 50, 50);
- fill(0);
- rect(Mushrooms.width/2, 640, 30, 8);
- rect(Mushrooms.width/2, 640, 8, 30);
- //NEGATIVE GREEN
- if (dist(Mushrooms.width/2, 700, mouseX, mouseY) < 50 / 2) {
- stroke(0);
- if (mousePressed) {
- strokeWeight(5);
- greenCC = greenCC -0.2;
- }
- }
- else {
- cursor(ARROW);
- noStroke();
- strokeWeight(1);
- }
- fill(0, 255, 0);
- rect(Mushrooms.width/2, 700, 50, 50);
- fill(0);
- rect(Mushrooms.width/2, 700, 30, 8);
- //POSITIVE BLUE
- if (dist(Mushrooms.width/1.3, 640, mouseX, mouseY) < 50 / 2) {
- stroke(0);
- if (mousePressed) {
- strokeWeight(5);
- blueCC = blueCC+0.2;
- }
- }
- else {
- cursor(ARROW);
- noStroke();
- strokeWeight(1);
- }
- rectMode(CENTER);
- fill(0, 0, 255);
- rect(Mushrooms.width/1.3, 640, 50, 50);
- fill(0);
- rect(Mushrooms.width/1.3, 640, 30, 8);
- rect(Mushrooms.width/1.3, 640, 8, 30);
- //NEGATIVE BLUE
- if (dist(Mushrooms.width/1.3, 700, mouseX, mouseY) < 50 / 2) {
- stroke(0);
- if (mousePressed) {
- strokeWeight(5);
- blueCC = blueCC -0.2;
- }
- }
- else {
- cursor(ARROW);
- noStroke();
- strokeWeight(1);
- }
- fill(0, 0, 255);
- rect(Mushrooms.width/1.3, 700, 50, 50);
- fill(0);
- rect(Mushrooms.width/1.3, 700, 30, 8);
- //RESET BUTTON
- if (dist(1536, 675, mouseX, mouseY) < 100 / 2) {
- stroke(0);
- if (mousePressed) {
- strokeWeight(5);
- redCC = 1;
- greenCC = 1;
- blueCC = 1;
- }
- }
- fill(0,0,0);
- ellipse(1536,675,75,75);
- fill(255,255,255);
- textMode(CENTER);
- text("RESET",1518,680);
- rectMode(CENTER);
- fill(255, 0, 0);
- }
1