【问题标题】:How to create a collage in JES如何在 JES 中创建拼贴画
【发布时间】:2014-09-13 02:45:53
【问题描述】:

我有一个项目要创建一个拼贴画,其中包含 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)

【问题讨论】:

    标签: python jython jes


    【解决方案1】:

    您的代码中有一些缩进错误。我不知道这是否是您将代码复制并粘贴到 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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-30
      • 1970-01-01
      • 2011-11-29
      • 1970-01-01
      • 2015-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多