我有一个项目要创建一个包含 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)