Flipping entire output (pixels)
in
Programming Questions
•
6 months ago
Hi,
I've found some examples that effectively flip an individual image inside a sketch but what I need to do is reverse (horizontally) the entire output all at once. This is so that I can rear-project the output onto a screen.
I've tried changing the image/video examples to work on all pixels but the best result so far has been to mirror the right side of the screen onto the left (although, it is also possible that the entire output is being flipped, with half of it landing outside the window...?) with the following code.
loadPixels();
for(int pw = 0; pw < width; pw++){
for(int ph = 0; ph < height; ph++){
pixels[pw + ph*width] = pixels[(width - pw - 1) + ph*width];
}
}
updatePixels();
I've tried changing around lots of different ways but without properly understanding the calculations, I've just been making noisy pixel patterns which, while cool looking, are not what I need.
Any help would be much appreciated, thanks in advance!
1