While you are working on the assignment, you must save and test your work every 20 to 40 lines. These are your "restore points" that I will discuss in class. Some of the restore points must be submitted along with your final program.
Beginning with this program, you'll need to follow all of our class programming style guidelines. One of the most important things for this program is that you do incremental development and testing. This means that you stop every 20 to 40 lines of code, check to make sure that your work compiles, and do whatever testing is possible at that point. When you are satisfied with the testing, make a copy of your program at that point. For example, if you call your program clock.cxx, then the copies that you make can be named clock-1.cxx, clock-2.cxx, and so on.
This homework is open, so that you may work with others. However, you need to understand everything that you turn in (otherwise you'll do poorly on later assignments and quizzes).
For all the homework assignments, including this one, you may submit to Dora and then check whether you passed her tests. If you did not pass the tests, then you should fix the problem and resubmit. You may resubmit as often as needed before the deadline. (However, for the lab exams, you may submit only once.)
The purpose of this assignment is to make sure that you know how to write a small program that includes some graphics, a function that another programmer has written, and functions that use reference parameters.
Write a void function with two parameters. The first parameter, a double number called cc, will control colors in a way that I'll describe in a moment. The second parameter, an int called s, is the size (in pixels) of a graphics window that has already been opened. The function calls putpixel to set the color of every pixel in the graphics window (both the row and column could be from 0 to s-1). For a pixel that is in row number x and column number y, you should calculate the color by these formulas:
int(255 * pow((s+y-x)/denominator, -cc/6.0))
int(255 * pow((y+x)/denominator, cc/6.0))
color = COLOR(0, 0, blue_amount);This uses the COLOR function to create a color that has no red, no green and an amount of blue that depends on the blue_amount variable.
Extra requirement: The function must calculate the number cc/6.0 or -cc/6.0 only once. Don't keep calculating this value over and over. Calculate it once and store the result in a local variable. This makes the function more efficient.
As part of this assignment, you must also write a small main program that opens a graphics window of size 200 x 200. The program then calls your function repeatedly with a value of s=200 and values of cc from -12 to +12 in steps of 0.1. (Start with d=-12, then -11.9, then -11.8, and so on.) Do this inside a loop, and at the end of the loop's body give a small delay by calling delay(1).
When you run the program, the window will open and be shaded with cc=-12 (which goes from blue in the lower left corner to black in the upper right). As the program runs, you'll see the shading change.
Write a new program that opens a 200 by 200 graphics window and then repeatedly does these things:
Work should be submit part IIA to Dora by 9am on Wednesday, Feb 5. And you should bring a printout of the program to your recitation to turn in to the TA. Part IIB is due one week later.
Students who do not give a printout to the TA during recitation will have a 2 point penalty (20%) on that part of the program. Students who submit work after 9am on Wednesday will have an additional penalty: -1 point for any late Wednesday submission; -1 additional point for each day through Monday. No submissions after Monday.