很傻很天真的编程问题 by Using Jyphon
使用Jython Environment for Student编程问题:
Write a program that reduces the green and increases the blue in the top third of a picture and negates the bottom third. Your color reduction function(s) should be as general as possible, that is, they can reduce or increase by any given amount.
我的解答:
def redneg(a,b):
# this a,b are customize!
file = r"D:\Picture\gzjietu.jpg"
pic = makePicture(file)
for x in range(0,getWidth(pic)):
for y in range(0,getHeight(pic)/3):
px = getPixel(pic,x,y)
setGreen(px,getGreen(px)*a)
setBlue(px, getBlue(px)*b)
for x in range(0,getWidth(pic)):
for y in range(getHeight(pic)-getHeight(pic)*(2/3),getHeight(pic)):
px = getPixel(pic, x, y)
red = getRed(px)
blue = getBlue(px)
green = getGreen(px)
newColor = makeColor(255-red, 255-green, 255-blue)
setColor=(px,newColor)
repaint(pic)
===============
然后我后面的negative picture code好像没用啊
解释器也没说我哪里出问题