Why can't I get this simple image to fade?
in
Programming Questions
•
2 years ago
Hi all...
I feel like I'm missing something very simple here. I'm creating a simple image of random colored pixels and want the red value of each pixel to increase step by step. For the life of me I can't figure out why I'm not seeing the image change tint. What am I missing? Here's the code...
PImage img;
void setup()
{
frameRate(5);
size(200, 200);
img = createImage(100, 100, RGB);
for(int i=0; i < img.pixels.length; i++) {
img.pixels[i] = color(random(0,255),random(0,255), random(0,255));
}
}
void draw()
{
background(204);
for (int i = 0; i < img.pixels.length; i++) {
float r = red(img.pixels[i]);
float g = green(img.pixels[i]);
float b = blue(img.pixels[i]);
if (r < 254.0) {
r = r + 1.0;
}
color c;
c = color(r,g,b);
img.pixels[i] = c;
}
image(img, 50, 50);
println(frameCount);
}
I feel like I'm missing something very simple here. I'm creating a simple image of random colored pixels and want the red value of each pixel to increase step by step. For the life of me I can't figure out why I'm not seeing the image change tint. What am I missing? Here's the code...
PImage img;
void setup()
{
frameRate(5);
size(200, 200);
img = createImage(100, 100, RGB);
for(int i=0; i < img.pixels.length; i++) {
img.pixels[i] = color(random(0,255),random(0,255), random(0,255));
}
}
void draw()
{
background(204);
for (int i = 0; i < img.pixels.length; i++) {
float r = red(img.pixels[i]);
float g = green(img.pixels[i]);
float b = blue(img.pixels[i]);
if (r < 254.0) {
r = r + 1.0;
}
color c;
c = color(r,g,b);
img.pixels[i] = c;
}
image(img, 50, 50);
println(frameCount);
}
1