User Tools

Site Tools


cs276:mirrorlr
// Create a mirror image of the given object   
void mirrorLeftRight(PImage pi) {
  int mirrorPoint = pi.width/2;
  pi.loadPixels();
  for (int row = 0; row < pi.height; row++) {
    for (int col = 0; col < mirrorPoint; col++) {
      color c1 = pi.get(col, row);
      color c2 = pi.get(pi.width - col - 1, row);
      pi.set(col, row, c2);
      pi.set(pi.width - col - 1, row, c1);
    } 
  }
  pi.updatePixels();
}
cs276/mirrorlr.txt · Last modified: 2007/10/02 17:17 by scarl