Wednesday, December 18, 2013

Mirror an Image Horizontally

def mirrorHorizonatal (source):
  height = getHeight (source)
  mirrorPoint = height/2
  for x in range (0, getWidth(source)):
    for y in range (0, mirrorPoint):
      topPixel = getPixel (source, x, y)
      bottomPixel = getPixel (source, x, height - y - 1)
      color = getColor (bottomPixel)
      setColor (topPixel, color)
  repaint(source)

No comments:

Post a Comment