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
pix = getPixel(picture, x, y)
setColor(canvasPix, getColor(pix))
return canvas
```
You might also like to view...
In SharePoint, a(n) ________ is a collection of announcements, links, surveys, discussion boards, or tasks
Fill in the blank(s) with correct word
Referring to the figure above, if you clicked the green check mark (Enter button) in the Quick Tag Editor window, what would happen?
A. The opening tag would be changed to h2. B. The closing tag would be changed to h2. C. Both a and b. D. Neither a nor b.