One of the most common transitions in movies is fade to black. Let’s implement that. Take a picture as input and copy that into the first frame of the movie. For the next 5 frames, copy the picture but make every 10th pixel black. Then for the next 5 frames, make every 9th and 10th pixel black. Continue the process until all the pixels are black.

What will be an ideal response?


```
def fadeToBlack(directory, picture):
#if each frame has 10 pixels changed, max frame is width/10
width = getWidth(picture)
height = getHeight(picture)
for num in range (1 ,10):
canvas = makeEmptyPicture (width,height)
copy(pic, canvas, 0, 0)
val = 10-num+1
makeBlack(canvas, val)
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 makeBlack(picture, val):
pixels = getPixels(picture)
for increase in range(val, 11):
for pixelIndex in range(0, len(pixels), increase):
setColor(pixels[pixelIndex], makeColor(0,0,0))
```

Computer Science & Information Technology

You might also like to view...

What is wrong with the following while loop? while (sum<= 1000) { sum = sum – 30; }

a. The parentheses should be braces. b. There should be a semicolon after while (sum <= 1000). c. sum = sum – 30 should be sum = sum + 30 or else the loop may never end. d. None of the above.

Computer Science & Information Technology

A textbox control will display as Unbound if it is linked to a field

Indicate whether the statement is true or false

Computer Science & Information Technology

A JavaScript ____ is an action script that allows you to add dynamic content to your web pages.

A. action B. event C. behavior D. trigger

Computer Science & Information Technology

You would use AND() in a nested COUNTIF() function if you wanted to make sure the data met one set of criteria AND was included in the count total.

a. true b. false

Computer Science & Information Technology