Create a movie where an input picture becomes smaller with successive frames. Paste the whole picture into the first frame, then reduce the size by 5% in successive frames.

Note: An answer could just make use of the clip method for this, but since the instructions clearly state to reduce the size by a percentage, a better solution is to scale the whole image.


```
def shrinkPicture(directory, picture):
#if each frame has 5 percent changed, max frame is width/20
width = getWidth(picture)
height = getHeight(picture)
for num in range (1 ,width/20):
canvas = makeEmptyPicture (width,height)
percent = 1.0-(0.05*num)
scaledPicture = scaleDown(picture, percent)
copy(scaledPicture, canvas, 0, 0)

numStr=str(num)
if num < 10:
writePictureTo ( canvas , directory +"//frame0"+ numStr +".jpg")
elif num >= 10:
writePictureTo ( canvas , directory +"//frame"+ numStr +".jpg")
movie = makeMovieFromInitialFile(directory+"/frame00.jpg");
return movie

def scaleDown(picture, percentScale):
width = getWidth(picture)
height = getHeight(picture)
newWidth = int(width*percentScale)
newHeight = int(height*percentScale)
canvas = makeEmptyPicture(newWidth, newHeight)

for x in range(0, width):
for y in range(0, height):
xNew = int(x*percentScale)
yNew = int(y*percentScale)
if xNew canvasPix = getPixel(canvas, xNew, yNew)
pix = getPixel(picture, x, y)
setColor(canvasPix, getColor(pix))
return canvas
```

Computer Science & Information Technology

You might also like to view...

?What determines the size of words in a word cloud?

A. ?length of the word or phrase B. ?difficulty in pronouncing the word or phrase C. ?whether the word is a pronounĀ  D. ?frequency of occurrence of the word in source documents

Computer Science & Information Technology

List and describe the two different types of RFID tags?

What will be an ideal response?

Computer Science & Information Technology

Convert binary 110101011000 to octal and to hexadecimal.

What will be an ideal response?

Computer Science & Information Technology

A closing line at the end of a letter, such as Yours Truly, is the ________

Fill in the blank(s) with correct word

Computer Science & Information Technology