如何在JE中创建拼贴

2024-06-30 07:42:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个项目,创建一个拼贴与6个副本的图像,有些翻转,有些颜色变化,等等。我对所有这些都是全新的,几乎不知道我在做什么。我写了我的代码,但是当我在JES和commandexplore(newpicture)中测试时,会弹出一个名为“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)

Tags: 代码颜色getwidthgetheightnewpictureapixelbigpicturebluepicture
1条回答
网友
1楼 · 发布于 2024-06-30 07:42:22

代码中有一些缩进错误。我不知道这是否是复制并粘贴代码到堆栈溢出的结果。在

发现的错误:

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

还有下面的代码行,你在上面。这些行应该在定义了函数之后进行。在

verticalPicture = flipVertically(myPict)
redPicture = matchRedToGreen(myPict)
negativePicture = negative(myPict)
bluePicture = clearBlue(myPict)
clockwisePicture = rotateC90(myPict)
newpicture = makeCollage(myPict)
explore(newpicture)

相关问题 更多 >