0

我有一个项目要创建一个包含 6 个图像副本的拼贴画,其中一些图像被翻转,一些图像发生了颜色变化等。我对这一切完全陌生,几乎不知道我在做什么。我写了我的代码,但是当我在 JES 和命令 explore(newpicture) 中测试它时,会弹出一个标题为“无”的白框。我试图弄乱它,但被卡住了。在此之前,我拥有所有用于翻转、更改颜色百分比等的定义。我想我的问题是我的测试不正确,或者它与下面的偏移或拼贴代码有关。为了测试我输入:

    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)
4

1 回答 1

0

您的代码中有一些缩进错误。我不知道这是否是将您的代码复制并粘贴到 Stack Overflow 中的结果。

发现的错误:

  • return语句makeCollage()需要再缩进一个空格。
  • for 循环后面的语句offsetPicture()需要缩进。

还有您在顶部的以下代码行。这些行应该在您定义函数之后进行。

verticalPicture = flipVertically(myPict)
redPicture = matchRedToGreen(myPict)
negativePicture = negative(myPict)
bluePicture = clearBlue(myPict)
clockwisePicture = rotateC90(myPict)
newpicture = makeCollage(myPict)
explore(newpicture)
于 2014-09-13T08:33:22.677 回答