【发布时间】:2018-11-02 22:29:17
【问题描述】:
对于我的任务,我们必须将我们校园的照片复制到一张空白的白色图像上,然后通过交换羚羊和长耳兔的鹿角和耳朵来制作 2 种不同的鹿角羚。我选择解决的第一步是将 GCU 校园复制到白色图像。我的程序加载并运行,但是当它显示带有复制像素的新画布时,它只显示 GCU 校园的右下角复制到(仍然大部分是空白的)画布的左上角。我试过切换目标和源。我尝试手动输入校园的像素高度和宽度,而不是使用 getHeight\Width。我基本上只是复制了示例代码并插入了我的变量,但它仍然不起作用。任何帮助将不胜感激。这是我的代码:
setMediaPath()
lopefile= getMediaPath("antelope.jpg")
lope= makePicture(lopefile)
jackfile= getMediaPath("jackrabbit.jpg")
jack= makePicture(jackfile)
GCUfile= getMediaPath("campus.jpg")
GCU= makePicture(GCUfile)
canvasfile= getMediaPath("canvas.jpg")
canvas= makePicture(canvasfile)
#this will copy the GCU picture to the blank canvas for the background
def makeBackground():
targetX = 0
for sourceX in range(0,getWidth(GCU)):
targetY = 0
for sourceY in range(0,getHeight(GCU)):
color = getColor(getPixel(GCU,sourceX,sourceY))
setColor(getPixel(canvas,targetX,targetY), color)
targetY = targetY + 1
targetX = targetX + 1
show(canvas)
return (canvas)
makeBackground()
【问题讨论】:
-
另外,如果您对尺寸感到好奇,GCU 图片为 264x620,空白画布为 1440 x 2560