我有一个项目,创建一个拼贴,一个图片的6个副本,一些翻转,一些颜色变化,等等。我对所有这些都是全新的,我几乎不知道我在做什么。我写了我的代码,但当我在JES和命令探索(新图片)中测试它时,会弹出一个标题为“None”的白色框。我试过把它弄乱,但我被困住了。我有我所有的缺点之前,翻转,改变颜色百分比,等等。我想我的问题是,我测试不正确,或者是我的胶印或拼贴代码下面。为了测试,我输入:
verticalPicture = flipVertically(myPict)
redPicture = matchRedToGreen(myPict)
negativePicture = negative(myPict)
bluePicture = clearBlue(myPict)
clockwisePicture = rotateC90(myPict)
newpicture = makeCollage(myPict)
explore(newpicture)
def offsetPicture(littlePicture, bigPicture, xOffset, yOffset):
for aPixel in getPixels(myPict):
littleX = getX(aPixel)
littleY = getY(aPixel)
bigX = littleX + xOffset
bigY = littleY + yOffset
bigPicturePixel = getPixel (bigPicture, bigX, 375)
setColor(bigPicturePixel, getColor (aPixel))
def makeCollage(myPict):
newWidth = 3*getWidth(myPict)
newHeight = 2*getHeight(myPict)
bigPicture = makeEmptyPicture(newWidth, newHeight)
offsetPicture(littlePicture, bigPicture, 0, 0)
offsetPicture(clockwisePicture, bigPicture, getWidth(myPict), 0)
offsetPicture(redPicture, bigPicture, 0, getHeight(myPict))
offsetPicture(bluePicture, bigPicture, 2*getWidth(myPict), 0)
offsetPicture(verticalPicture, bigPicture, getWidth(myPict), getHeight(myPict))
offsetPicture(negativePicture, bigPicture, 2*getWidth(myPict), 2*getHeight(myPict))
return (bigPicture)发布于 2014-09-13 08:33:22
代码中有一些缩进错误。我不知道这是否是将代码复制和粘贴到堆栈溢出中的结果。
发现的错误如下:
return语句makeCollage()需要缩进一个空间。offsetPicture()中for循环之后的语句需要缩进。另外,下面的代码行在顶部。这些行应该是在定义了函数之后进行的。
verticalPicture = flipVertically(myPict)
redPicture = matchRedToGreen(myPict)
negativePicture = negative(myPict)
bluePicture = clearBlue(myPict)
clockwisePicture = rotateC90(myPict)
newpicture = makeCollage(myPict)
explore(newpicture)https://stackoverflow.com/questions/25819356
复制相似问题