User Tools

Site Tools


This is an old revision of the document!

Note: this code example only shows the function needed to perform the operation. You need to provide your own setup() and draw() or other functions to test it.

Function to mirror an image around a horizontal line void mirrorHorizontal(PImage pi) { int mirrorPoint = pi.height / 2; color topPixel; pi.loadPixels(); loop through all columns

  for (int x = 0; x < pi.width; y++) {
     // loop from 0 to just before the mirrorPoint
     for (int y = 0; y < mirrorPoint; y++) {
        topPixel = pi.get(x, y);
        // put the color into the pixel at (height-1) - y
        pi.set(pi.height - 1 - y, y, topPixel);


cs276/mirrorhorz.1191271736.txt.gz · Last modified: 2007/10/01 15:48 by scarl