def brighter(picture):
for px in getPixels(picture):
r = getRed(px) #取得紅色的數值
g = geGreen(px)
b = getBlue(px)
new_color = makeColor(r*1.3, g*1.3, b*1.3) #自定義顏色
setColor(px, new_color) #改顏色
#load program
f = pickAFile() #給定路徑
p = makePicture(f) #開啟圖片
brigher(p) #執行調亮函數
explore(p) #開啟圖片
def make_sunset(picture):
for px in getPixels(picture):
b = getBlue(px) #取得藍色的數值
g = geGreen(px)
setBlue(p, b*0.7) #重設藍色的數值
setGreen(p, g*0.7)
#load program
f = pickAFile()
p = makePicture(f)
make_sunset(p)
explore(p)
def negative(picture):
for px in getPixels(picture):
r = getRed(px) #取得紅色的數值
g = geGreen(px)
b = getBlue(px)
negColor = makeColor(255-r, 255-g, 255-b) #自定義顏色
setColor(px, negColor) #改顏色
#load program
f = pickAFile()
p = makePicture(f)
negative(p)
explore(p)
The RGB scale is calibrated so that when a color's three red/green/blue numbers are equal, the color is a shade of gray.
def grayscale(picture):
for px in getPixels(picture):
x = (geRed(px) + geGreen(px) + getBlue(px))/3
grayColor = makeColor(x, x, x)
setColor(px, grayColor)
#load program
f = pickAFile()
p = makePicture(f)
grayscale(p)
explore(p)
A : 複製上半段旋轉至下半段
Index means the distance of the first index to our current index (counting from the left), and len(list) – 1 – index means the distance of the last index to the mirrored point (counting from the right).