我有一个学校项目,我必须创建一个拼贴画,多次显示图像,每个图像都有变化。我对前一张图片的填充尺寸有一个问题,但是解决了这个问题,现在又出现了另一个问题。当运行拼贴程序时,它为每个功能创建一个不同的图像来更改图像,然后它显示一个空白的画布,其中包含消息"图片,文件名无高度700宽度515"在JES。我需要将所有图像显示在一个画布上并进行更改。任何帮助表示赞赏
def copy(sourcePic,targetPic, tarX, tarY):
pictureTurtle = makePicture(getMediaPath("turtle.jpg"))
targetX = tarX
for sourceX in range(0, getWidth(sourcePic)):
targetY = tarY
for sourceY in range(0, getHeight(sourcePic)):
pxColor = getPixel(sourcePic, sourceX, sourceY)
txColor = getPixel(targetPic, targetX, targetY)
target = targetY + 1
targetX = targetX + 1
def lighten(pictureTurtle):
pictureTurtle = makePicture(getMediaPath("turtle.jpg"))
for pxColor in getPixels(pictureTurtle):
color = getColor(pxColor)
color = makeLighter(color)
setColor(pxColor, color)
show(pictureTurtle)
def negative(pictureTurtle):
pictureTurtle = makePicture(getMediaPath("turtle.jpg"))
for pxColor in getPixels(pictureTurtle):
red = getRed(pxColor)
green = getGreen(pxColor)
blue = getBlue(pxColor)
negColor = makeColor(255-red,255-green,255-green)
setColor(pxColor, negColor)
show(pictureTurtle)
def grayscale(pictureTurtle):
pictureTurtle = makePicture(getMediaPath("turtle.jpg"))
for pxColor in getPixels(pictureTurtle):
intensity = (getRed(pxColor)+getBlue(pxColor))/3
setColor(pxColor,makeColor(intensity,intensity,intensity))
show(pictureTurtle)
def rotate(pictureTurtle):
pictureTurtle = makePicture(getMediaPath("turtle.jpg"))
w,h = getWidth(pictureTurtle), getHeight(pictureTurtle)
for y in xrange(h):
for x in xrange(w):
color = getColor(getPixel(pictureTurtle, x, y))
targetPixel = getPixel(pictureTurtle, x, y)
setColor(targetPixel, color)
show(pictureTurtle)
def collage():
pictureTurtle = makePicture(getMediaPath("turtle.jpg"))
canvas = makeEmptyPicture(515, 700)
copy(pictureTurtle,canvas,0,getHeight(canvas)-getHeight(pictureTurtle)-5)
lighten(pictureTurtle)
copy(pictureTurtle,canvas,50,getHeight(canvas)-getHeight(pictureTurtle)-5)
negative(pictureTurtle)
copy(pictureTurtle,canvas,100,getHeight(canvas)-getHeight(pictureTurtle)-5)
grayscale(pictureTurtle)
copy(pictureTurtle,canvas,12,75-5)
rotate(pictureTurtle)
copy(pictureTurtle, canvas,62, 75-5)
show(canvas)
return(canvas)