Due midnight 29 September 2011
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.
There are five graphics primitives you will implement this week: Point, Line, Circle, Ellipse, and Polyline. The specific functions and data types are outlined in the C system specifications. If your code follows the specification, you will be able to compile and run the test programs.
Lines: Implement Bresenham's line-drawing algorithm as the basis for the Line_draw() function. Use the version corrected for screen coordinates in the lower left of the pixel.
Calculate how many lines per second your algorithm can draw using this test program. Report your results for running it on one of the computer lab minis.
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.
- Use the following test program 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.
- Use the following test program to create required picture #2. Note that the function subdivide does need to access the values of the line endpoints. So if your structure fields are named differently, you'll need to edit the test program so it accesses the values correctly.
- Here is a polyline test function. Note the difference in the two green boxes on the lower half of the image. The left one is drawn counter-clockwise. The right one is drawn clockwise.
- 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.
- Giving your routines the ability to draw dashed lines and/or circles & ellipses (easy)
- 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).
Make a child wiki page from your main CS 351 wiki page. Give it the label cs351f11project3. Please follow the format below.
- 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.
Put your code files in your private handin folder as a single zip or tar file. Put your writeup on the wiki. Give it the label cs351f11project3.