Issues with Colour corrector pixels code.
in
Programming Questions
•
1 year ago
My code includes 6 buttons which work fine, however when I try to attach something to the mouse clicks it never works. I am trying to connect a + and - button to R, G and B to increase and decrease each one separately however when I copy my code into to the mousePressed section, it does not recognise [i] in terms of pixels. Can someone please help. I am new to processing and suck at it!
- PImage Mushrooms;
- PImage Mushrooms2;
- int valueRed = 155;
- 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);
- Mushrooms.loadPixels();
- Mushrooms2.loadPixels();
- for (int i=0; i < dimension; i+=1) {
- Mushrooms2.pixels[i] = color( red(Mushrooms.pixels[i]), green(Mushrooms.pixels[i]), blue(Mushrooms.pixels[i]));
- }
- image(Mushrooms, 0, 0);
- image(Mushrooms2, 1024, 0);
- smooth();
- }
- void draw() {
- rectMode(CENTER);
- fill(255, 0, 0);
- //POSITIVE RED
- if (dist(Mushrooms.width/4, 640, mouseX, mouseY) < 50 / 2) {
- stroke(0);
- if (mousePressed) {
- strokeWeight(5);
- Mushrooms2.pixels[i] = color( red(Mushrooms.pixels[i]), green(Mushrooms.pixels[i]), blue(Mushrooms.pixels[i]));
- }
- }
- 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);
- }
- }
- 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);
- }
- }
- 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);
- }
- }
- 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);
- }
- }
- 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);
- }
- }
- 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);
- }
Any help would be appreciated
1