我有一个项目来创建一个拼贴画,其中包含一些图像的副本,其中一些是翻转的,一些是颜色变化的等等。我对这一切都是全新的,并且几乎不知道我在做什么。我写了我的代码,但是当我在JES和命令探索(newpicture)中测试它时,弹出一个标题为“无”的白框。我试图弄乱它,但我被卡住了。在此之前我有我的所有defs用于翻转,改变颜色百分比等。我想我的问题是我测试不正确或者我的偏移或拼贴代码如下。 为了测试我正在输入:
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)
答案 0 :(得分:0)
您的代码中存在一些缩进错误。我不知道这是否是将代码复制并粘贴到Stack Overflow中的结果。
发现错误:
return
makeCollage()
语句需要缩进一个空格。offsetPicture()
中for循环后的语句需要缩进。您还可以在顶部找到以下代码行。这些行应该在您定义函数之后进行。
verticalPicture = flipVertically(myPict)
redPicture = matchRedToGreen(myPict)
negativePicture = negative(myPict)
bluePicture = clearBlue(myPict)
clockwisePicture = rotateC90(myPict)
newpicture = makeCollage(myPict)
explore(newpicture)