CS21 Lab 5: Graphics

Due 11:59pm Sat, Oct 12

As always, run update21 to create this week's lab directory and copy over any starting-point files.

For this lab we will use the Zelle graphics library.

1. word circles

Write a program that asks the user to enter some text or a phrase and then splits the phrase into individual words and displays each word in a separate circle. The word circles should have randomly-chosen locations and colors, but adjust their sizes according to the length of the word.

Here are two examples:

$ python wordcircles.py

text: we love computer science!!

$ python wordcircles.py

text: Supercalifragilisticexpialidocious!  Even though the sound of it Is something quite atrocious

2. checkers

Write a program to display an 8x8 checkers board. Your program should first ask the user for the size of the board (either width or height, but the board should be square). Then create and display the board (you choose the two colors). Finally, let the user click the mouse a few times (6-12?) to place a few checkers on the board. Just place the pieces wherever they click -- they don't need to be aligned with the board spaces, but they should be the appropriate size for the given checker board. Your program should also tell the user, in the graphics window, how many more mouse-clicks are needed and why (see the video).

Here's a sample run of the program:

$ python checkers.py

window height: 400

NOTE: the Zelle graphics library has a GraphWin method called setCoords() that might be useful here. It takes 4 arguments: xll, yll, xur, yur, where ll means lower-left and ur means upper-right. Calling setCoords(0,8,8,0) may be useful for this problem...

3. closing credits

Write a program to display the closing credits for a fake movie. You may design the look of the credits however you want (e.g., colors used, font sizes, scroll bottom-to-top or fade in/out, etc).

Assume you are given 3 lists with credit data in them: cast, crew, and misc. Here is the format of each python list:

  cast = ["Jason Waterman:The Professor", "Andy Danner:A.J. Burnett"]
  crew = ["Directed by:RICH WICENTOWSKI", "Written by:JEFF KNERR"]
  misc = ["""
  No animals were injured during 
  the making of this film!""",
  The events, characters and firms depicted in 
  this photoplay are fictitious.  Any similarity 
  to actual persons, living or dead, or to 
  actual events or firms is purely coincidental. """]

Your closing credits should show all of the data in the 3 given lists and make sure it is readable to the viewer. Here are 2 examples (you don't have to do these specific effects -- create your own effects or use these if you want):

NOTE: Unlike the choppy youtube videos shown above (due to screen-capturing), your animations or transitions should be smooth.

Also NOTE: for Zelle graphics, valid font sizes are 8-36; valid font families are "arial", "helvetica", and "courier".

Once you are satisfied with each program, hand them in by typing handin21 at the unix prompt.