Due 1 March, 2018
In this assignment you will start building your graphics system in earnest. You'll implement several different graphics primitives, including lines, circles, ellipses, and polylines. You can work in pairs, starting with this assignment.
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 robot lab dwarves.
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.
The following test program may help you to debug. It's output should look like the image below.
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. You can find the instructions for that in my lecture notes. Note 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 test program for the polyline functions. 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, or anything else of your choice, using these routines (line/polyline, circle, ellipse). Be creative. If you are working with a partner, each of you must make your own image for this task.
- Don't forget to make a couple of images for your portfolio.
Extensions are your opportunity to extend the project in a way that is of interest to you. The extensions below are suggestions, but you can also choose your own. Extensions are graded on quality and effort. Multiple simple extensions may be worth the the same or even less than a single more extensive extension done well.
- Give your routines the ability to draw dashed lines and/or circles & ellipses. Parameterize the spacing.
- Anti-alias your line-drawing and circle drawing routines.
- Create a flood-fill algorithm so that you can fill in polygons and circles.
- Allow the user to specify arbitrary orientations for the ellipse algorithm.
- Build a faster line algorithm using symmetry and multiple steps or just through better coding.
Make a child wiki page from your main CS 351 wiki page. Give it the label cs351f18project3. Put up your required and portfolio images along with brief descriptions and relevant information. If you are working with a partner, make only one wiki page, but you must each make your own images when there is creativity involved. You must also each make your own portfolio images.
Put your code in a project folder in your Private handin folder. Put your writeupon the wiki. Give it the label cs351f18project3.