每当我尝试在 JES 中运行诸如此类的程序时,每当我在括号内放置任何内容时,程序都无法运行?!我究竟做错了什么!当我尝试运行程序并输入图像(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 pict
prog 3:这应该编写一个 prog 来混合两张图片,1. 混合第一张图片的前三分之一 2. 然后在中间三分之一处混合两张图片 tpgether,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)