Untitled

沿著垂直線鏡像

Untitled

def mirrorVertical(source):
    mirrorPoint = getWidth(source)
    mirrorPoint = width / 2
    for y in range (0, getHeight(source)):
        for x in range(0, mirrorPoint):
            leftPixel = getPixel(source, x, y)
            rightPixel = getPixel(source, width -1 -x, y)
            setColor(rightPixel, getColor(leftPixel))

##f = pickAfile()
##p = makePicture(f)
#mirrorVertical(p)

沿著水平線做鏡像

Untitled

def mirrorHorizontal(source):
    for x in range(getWidth(source)):
        for y in range (getHeight(source) / 2):
            p1 = getPixel(source, x, y)
            p2 = getPixel(source, x, getHeight(source) -1 -y) 
            setColor(p2, getColor(p1))

Untitled

diagonal = 對角線

Untitled

當x and y相等的時候取其值

Untitled

def mirrorDiagonal(pic):
    for y in range(getHeight(pic)):
        for x in range(y):
            p1 = getPixel(pic, x, y)
            p2 = getPixel(pic, y, x)
            setColor(p2, getColor(p1))

Untitled

Untitled

Untitled