update pixels in random order?
in
Programming Questions
•
2 years ago
Hi there,
After some time searching the web and trying different things I can't figure this out. So I hope somebody on the forums can assist me with this.
I have a picture loaded in, and now I want all the pixels to turn black, in a random order, and every pixel just once, so:
Can someone please help me?
Thanks in advance!
After some time searching the web and trying different things I can't figure this out. So I hope somebody on the forums can assist me with this.
I have a picture loaded in, and now I want all the pixels to turn black, in a random order, and every pixel just once, so:
loadPixels();
if (i < (width*height)) {
pixels[i] = color(0);
i++;
}
updatePixels();
or
if (i < (width*height)) {
pixels[i] = color(0);
i++;
}
updatePixels();
loadPixels();
if (i < width*height){
pixels[int(random(width*height))] = color(0);
i++;
}
updatePixels();
won't work because it goes over pixels more than once. Also I would like it to stop after it has changed all pixels to black.
if (i < width*height){
pixels[int(random(width*height))] = color(0);
i++;
}
updatePixels();
Can someone please help me?
Thanks in advance!
1