jeudi 2 avril 2015

(jython/ python)Can't seem to get the image copy I made in jython outside of my def

Hi I have a single block of code for an excersize I'm trying to write that I can't figure out why the copied image is not callable outside of the definition. Also I don't understand why or what to put in the brackets of the definition, or why I would, as the excersize is asking me to have the definition title written exactly as I currently have it. Also, why would I use the statement "return" as shown in some other code examples I've seen?


Do you spot any redundancies too? =\


Here's the Code:



def makeCopyOfAPicture(picOriginal):
source = pickAFile()
picOriginal = makePicture(source)
picWidth = getWidth(picOriginal)
picHeight = getHeight(picOriginal)
picCopy = makeEmptyPicture(picWidth, picHeight)
targetX = 0
for sourceX in range(0,getWidth(picOriginal)):
targetY = 0
for sourceY in range(0,getHeight(picOriginal)):
color = getColor(getPixel(picOriginal,sourceX,sourceY))
setColor(getPixel(picCopy, targetX, targetY), color)
targetY = targetY + 1
targetX = targetX + 1
show(picOriginal)
show(picCopy)
# print(picCopy)
# print(picOriginal)
return picCopy

makeCopyOfAPicture(picOriginal)


TIA!


Aucun commentaire:

Enregistrer un commentaire