标题:很傻很天真的编程问题 by Using Jyphon
只看楼主
qingmui
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-10-6
 问题点数:0 回复次数:1 
很傻很天真的编程问题 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好像没用啊
解释器也没说我哪里出问题
搜索更多相关主题的帖子: Using Jyphon 
2010-10-17 08:25
KLML88422
Rank: 2
来 自:火星
等 级:论坛游民
威 望:1
帖 子:34
专家分:20
注 册:2010-11-12
得分:0 
。。。。。。。。。。。。。。。。。
2010-11-19 09:07



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-323134-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021107 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved