I'm writing a code in Jython, that will copy part of one picture into an empty picture, but I want it to copy (let's say) 10 pixels less with each next row. I don't think I make sense, let me explain with an example. A picture 100 pixels by 100 pixels, the program will copy the first row (100pixels) of pixels into the new picture, but for second row of pixels I want it to copy only 90 pixels, then for the third row 80 pixels, and so on.
Here I have a code that will copy part of a picture, but it copies a square. So what should I add to make it do what I want. I'm guessing I'm supposed to do something with the for x in range
but I don't know what.
def copyPic():
file=pickAFile()
oldPic=makePicture(file)
newPic=makeEmptyPicture(getWidth(oldPic),getHeight(oldPic))
xstart=getWidth(oldPic)/2
ystart=getHeight(oldPic)/2
for y in range(ystart,getHeight(oldPic)):
for x in range(xstart, (getWidth(oldPic))):
oldPixel=getPixel(oldPic,x,y)
colour=getColor(oldPixel)
newPixel=getPixel(newPic,x,y)
setColor(newPixel,colour)
explore(newPic)