繁体   English   中英

如何在JES中创建拼贴

[英]How to create a collage in JES

我有一个项目,可以创建一个拼贴画,其中包含6张图像的副本,其中有些副本被翻转,有些副本具有颜色变化,等等。我对这一切都是全新的,几乎不知道我在做什么。 我写出了代码,但是当我在JES中测试它并命令Explore(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)

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

发现的错误:

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

还有下面几行代码位于顶部。 这些行应在定义函数之后进行。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM