currently, I'm doing it by running through pixels[] with a for loop, breaking apart each color into hue, saturation and brightness, affecting saturation or brightness, sending it back into pixels[], then doing an updatepixels(), like so:
loadPixels();
for (int i = 0; i < pixels.length; i++){
// get values from pixels[]
color c;
float h = hue(pixels[i]);
float s = saturation(pixels[i]);
float b = brightness(pixels[i]);
if (s > mod){ // we are changing saturation
s += mod;
}
// put values back in pixels
c = color(h, s, b);
pixels[i] = c;
}
updatePixels();
The main reason I would like to find another way to do this is to be able to progressively reverse the process. Going back and forth with this method slowly takes out information until the image is gone. Is there something equivalent to tint(), but for saturation and/or brightness?
Well, this might be a really easy one to solve, but for the life of me, I can't figure it out.
Let's say you have a variable int c = 0. You go c++ through every iteration of a loop, and you want it to loop back to 0 when you reach, say, 200. So doing this is easier:
c = (c+1) % 200;
Is there an equivalent, simple way to loop when you're
substracting from it, without having to do something like
if (c > 0){
c--;
}else{
c = 200;
}
In other words: if the value is 0, and it goes down 1, I want it to go back to the max value (in this case, 200).