Basic Graphics Programming

You may work with a partner of your choice for this lab. All work is to be done with both teammates working together at the computer. If you find that you absolutely can't schedule time to work together, split up for this assignment and turn in your own work. As always, feel free to ask lots of questions!

The graphics module

In your home directory, create a directory called graphicsIntro to hold your work for this assignment. Change to that directory in the terminal window.

Save this graphics.py file to the graphicsIntro directory that you just created.

You can open up graphics.py and look at it if you'd like. However, we won't be paying much attention for a while to what's in this class. Instead, we're going to use this module in our own programs.

Now similarly grab the file myArtwork.py and open it up. Read through the code and see if you can figure out what it will do.

To run your program, type:

python myArtwork.py

from the terminal window. What do you see? Try modifying the program to accomplish the following:

The documentation for graphics.py is at this web page (a link is also now on the Moodle home page). Take a few minutes to skim through the documentation to familiarize yourself with what's there, and where. Then try picking out a few methods that look like they might be interesting, and try them out. Modify your program to use other methods from this documentation page.

Your Own Design

Write a Python program named myDrawing.py. Your program should create a GraphWin object and, using the methods in graphics.py, draw a picture. Spend a little bit of time experimenting with the different methods, and then figure out how to combine these methods to draw more complex shapes or pictures. Use some arithmetic operations as part of your program.

Some suggestions:

Be creative, and have fun!

What to turn in

Turn in your work with Moodle. Creativity is highly valued! Again, only one member of a team needs to submit the work, but make sure that both team members names are in comments in the program.


Written by Amy Csizmar Dalal, Dave Musicant, and Jeff Ondich.