Handouts: Graphics Reference
Worked Example: Half Green, Target
File: short_film.py

Did you know that animated movies like Toy Story, Up, and Frozen are made using computer programs? In this assignment you are going to use a program to create a short film.

Display Message

Every movie has a beginning and an end. Sometimes it will start "Once Upon a Time...", sometimes it will start with a title, sometimes it will start with something sillier. At the end of the movie it sometimes says "The end."

Add a function to your program that will draw a message on the screen (on a black background) and leave the message for two seconds.

def display_message(canvas, message):
  ...

The start message should look like the screen below.

The font (and font size) that we used was:

canvas.set_font(label, "Papyrus", 40)

Make sure to color the text white! After two seconds you should remove the rectangle that is the background and the text that is the message. To do so you can use the delete function (which takes an object that was on the canvas and removes it).

canvas.delete(your_object)

Of course, you can use this function as much as you want to tell your story!

Setting Sun

Your movie must have one scene to start: A setting sun. First, draw the sky, the earth and a sun. Then, slowly animate the sun descending. The sky should take up the top half of the canvas, and the earth should take up the second half. Consider the following images from the start of the program, and the program after a few seconds.

get_sun_color Function

Write a function that takes some parameter, and returns the color of the sun. You should specify the parameter of this function: for example, the time (in number of frames since the beginning of the movie), or the y position of the sun, or anything else you think would be useful for getting the correct color of the sun.

def get_sun_color(...):
  ...
  return color

Have the function return "yellow", "orange", or "red" based on how many iterations have passed.

Finishing Up

After your movie ends, display a finishing message using your display_message() function defined earlier. The end message should look like the screen below.

Make It Better

Do anything you want to make your story more captivating than just a setting sun. Can you tell a tale of love or action? Don't forget to use functions to make your life easier.

You can also add more objects to make your scene more captivating. Add a rainbow (or a double rainbow)? Do you have an idea about what sunsets have always been missing? How about a lit up Bosphorus Bridge or Charles Bridge?