### Graphics Primitives

Due midnight 22 September 2008

In this assignment you will start building your graphics system in earnest. You'll implement several different graphics primitives, including lines, circles, ellipses, and basic polygons. It is strongly recommended that you work with a partner for the rest of the semester and split the work between you.

### Graphics Primitives

There are six graphics primitives you will implement this week: Point, Line, Circle, and Ellipse. The specific functions and data types are outlined in the C and C++ system specifications. If your code follows the specification, you will be able to compile test program 1.

**Lines**: Implement Bresenham's line-drawing algorithm as the
basis for the Line.draw() / Line_draw() function.

Calculate how many lines per second your algorithm can draw using this test program, which is set up to work with a C graphics environment (it ought to be trivial to convert to C++). Report your results with your lab writeup along with the clock speed of the computer you ran it on.

**Circles and Ellipses**: Implement the midpoint circle and ellipse
algorithms (only standard orientation is required for ellipses) as the
basis for the draw functions for these types.

For both the line and circle/ellipse algorithms, make sure to modify the algorithms to take into account the screen coordinate issues as outlined in the class and lab notes.

Here are example circle and ellipse algorithms drawn in the 1st quadrant. You are free to use these as templates for your own routines so long as you acknowledge this in comments within your code. They are from an older web site connected with the Hearn and Baker textbook. Note, however, that you will have to modify their code--put it in the 3rd quadrant--in order to make it correctly handle screen coordinate issues. Note also the order in which their setpixel routine takes its arguments.

**Required Pictures**

- Use the following C source file or C++ source file to create required picture #1. If you followed the design specifications, then you will not need to change the source file in order to create the picture.
- Do your best to create a 3-D looking picture of a car, train, plane, or spaceship using these routines (line/polyline, circle, ellipse). Be creative.

### Extensions

- Giving your routines the ability to draw dashed lines and/or circles & ellipses (e asy)
- Anti-aliasing your line-drawing and circle drawing routines (moderate)
- Creating a flood-fill algorithm so that you can fill in polygons and circles (moderate )
- Allowing the user to specify arbitrary orientations for the ellipse algorithm (difficult)
- Building a faster line algorithm using symmetry and multiple steps (challenging).

### Writeup

All writeups should suggest the format of a lab report. They do not have to be long, but need to provide enough information that I have some idea you knew what you were doing.

- Abstract: 200 word description (at most) of what you did and a picture to go along with it.
- Description of the task, in your own words. Be brief, but write it as though explaining it to a fellow student not in the course.
- Description of how you solved the task, including any key equations or algorithms. You should also include algorithms or descriptions of what you did for any extensions. Include pictures here.
- More pictures. Please put a caption on each picture explaining something about it. If you have nothing else, give it a name and indicate whose picture it is.
- Summary of what you learned.

### Handin

Put your code files in your handin folder. Send the prof an email with the URL for your writeup (wiki or standard web page) when it's done. In either case, please edit the assignment handin page on the wiki so there is a link to your assignment.