Wednesday, July 19, 2006
11
today we did modifying pieces of an image, copying, and mirroring
before&after pictures




here is the code for it:
def mirrorVertical(pic):
mid=getWidth(pic)/2
for x in range(1, mid + 1):
for y in range(1,getHeight(pic) + 1):
basePix=getPixel(pic, x,y)
changePix=getPixel(pic, getWidth(pic)-x, y)
setColor(changePix, getColor(basePix))
def mirrorHorizontal(pic):
mid=getHeight(pic)/2
for x in range(1,getWidth(pic) + 1):
for y in range(1, mid+1):
basePix=getPixel(pic, x,y)
changePix=getPixel(pic, x, getHeight(pic)-y)
setColor(changePix, getColor(basePix))
def doIt():
file=pickAFile()
pic=makePicture(file)
mirror(pic, 1)
show(pic)
def mirror(pic, axis):
if axis==1:
mirrorHorizontal(pic)
if axis==2:
mirrorVertical(pic)
today we did modifying pieces of an image, copying, and mirroring
before&after pictures




here is the code for it:
def mirrorVertical(pic):
mid=getWidth(pic)/2
for x in range(1, mid + 1):
for y in range(1,getHeight(pic) + 1):
basePix=getPixel(pic, x,y)
changePix=getPixel(pic, getWidth(pic)-x, y)
setColor(changePix, getColor(basePix))
def mirrorHorizontal(pic):
mid=getHeight(pic)/2
for x in range(1,getWidth(pic) + 1):
for y in range(1, mid+1):
basePix=getPixel(pic, x,y)
changePix=getPixel(pic, x, getHeight(pic)-y)
setColor(changePix, getColor(basePix))
def doIt():
file=pickAFile()
pic=makePicture(file)
mirror(pic, 1)
show(pic)
def mirror(pic, axis):
if axis==1:
mirrorHorizontal(pic)
if axis==2:
mirrorVertical(pic)
