CECS Home | ANU Home | Search ANU
The Australian National University
ANU College of Engineering and Computer Science
School of Computer Science
Printer Friendly Version of this Document

UniSAFE

Computer Graphics

ASCII Art Exercise

This is a simple programming exercise. It is not assessable, but will give you an idea of what computer graphics programming is about. It also is a good way to make sure your account in the Computer Science labs is set up correctly.

Download the CG ASCII source code. Extract the files with

% tar -xvf CG-Ascii.tar

This program is written in C. Most computer graphics code, including the examples in the textbook, is in C. If you only know Java, you'll still be able to do this exercise, and it will give you some practice in translating from one to the other which will be very useful later on.

To build and run the program:

% cd CG-Ascii
% make
% ./teletype

As supplied, the program doesn't do very much.

1. ClearBuffer() is supposed to fill the screen with spaces (ie blank). Fix this: you should see just three short horizontal lines.

2. Write the code for VertLine(), using the code for horizontal lines as a guide. You should see the digit nine being displayed, as if by a simple LED display.

3. Modify the digit() and main() functions in teletype.c to display either the current year, or the current day and month. (Four digits in total.)

Don't spend too much time on this, it's just a warm-up exercise. It does demonstrate some key points of graphics programming:

  • Raster display frame buffers are just memory.
  • Using primitives supplied by a library makes creating images easier.