例如,每当我尝试在JES中运行这样的程序时,无论何时我将任何东西放在括号中,程序都不能工作?!我到底做错了什么!当我尝试运行程序并键入image(pict)时,它只显示错误,全局找不到名称。def image(pict):
另外,我在下面写的代码有什么问题,它们不能运行,你也可以详细解释我代码的每个部分,因为我知道要写什么,但我不知道该做什么。
另外,如何使用while语句编写函数,即使用addLine()为地图上的多个路由添加路由,而不是使用输入?
def startEnvironemnt(pict):
a = pickAFile()
pict = makePicture(a)
sourceH = getHeight(pict)
sourceW = getWidth(pict)
canvas = makeEmptyPicture(sourceW, sourceH)
show(canvas)
show(pict)
explore(pict)程序2
def chromeKey(pict)
for x in range(0, getWidth(pict)):
for y in range(0, getHeight(pict)):
pix = getPixel(pict, x, y)
if(getRed(pix) + getGreen(pix) < getBlue(pix)):
setColor(pix, getColor(getPixel(canvas,x,y)))
return pictprog 3:这应该是写一个prog来混合两张图片,1.混合第一张图片的前1/ 3.然后在中间的1/3中滴血2.然后显示第二张图片的最后1/3
设置相同大小的源图像的程序
def blendImg():
#mark on the moon
a = pickAFile()
source = makePicture(a)
#WaterFall
b = pickAFile()
secondImg = makePicture(a)
sHeight = getHeight(secondImg)
sW = getWidth(secondImg)
canvas = makeEmptyPicture(sHeight, sW)
#Copy of pic 1, 94columns(1/3 of image)
sourceX=0
for targetX in range(0,94):
sourceY=0
for targetY in range(0, getHeight(source)):
color = getColor(getPixel(source,sourceX,sourceY))
setColor(getPixel(canvas,targetX,targetY),color)
sourceY = sourceY + 1
sourceX = sourceY + 1
#actual blending
blend = getWidth(source)-94
sourceX=0
for targetX in range(150,getWidth(source)):
sourceY=0
for targetY in range(0,getHeight(secondImg)):
sPixel = getPixel(source,sourceX+94,sourceY)
sImgPixel = getPixel(secondImg,sourceX,sourceY)
newRed = 0.25*getRed(sPixel)+0.25*getRed(sImgPixel)
newGreen = 0.25*getGreen(sPixel)+0.25*getGreen(sImgPixel)
newBlue = 0.25*getGreen(sPixel)+0.25*getGreen(sImgPixel)
nColor = makeColor(newRed,newGreen,newBlue)
setColor(getPixel(canvas,targetX,targetY),nColor)
sourceY = sourceY+1
sourceX = sourceX+1
sourceX=blend
for targetY in range(94+blend,94+getWidth(secondImg)):
sourceY=0
for targetY in range(0,getHeight(secondImg)):
color = getColor(getPixel(secondImg,sourceX,sourceY))
setColor(getPixel(canvas,targetX,targetY),color)
sourceY = sourceY + 1
sourceX = sourceX + 1
show(canvas)
return(canvas)发布于 2014-08-08 04:23:21
通常,您会想要尝试在stackoverflow上提出问题,以便每个问题都有一个问题。
要让第一个程序正常工作,您需要执行以下操作(不要键入>>>,这只是一个提示):
>>> picture = makePicture(pickAFile())
>>> startEnvironemnt(picture)注意,在函数的定义中,您使用了pict,在提示符下我使用了picture。只要在提示符处使用相同的名称,就可以使用您喜欢的任何非保留字。如果它告诉您没有定义pict,那么在尝试使用它之前,请确保您已经在代码中的某个位置使用了像pict = makePicture(pickAFile())这样的赋值语句为它赋值。
程序2在第一行的末尾缺少一个冒号,因此这不太可能起作用。
我认为你应该编辑你的问题,将while循环部分放到一个单独的问题中。
https://stackoverflow.com/questions/25104464
复制相似问题