http://copland.udel.edu/~pconrad/cisc181h/04S/labs/gnuplot.htmlYou do NOT have to turn in those exercises (the ones in gnuplot.html) for credit, but you should complete them at least far enough to familiarize yourself with the general idea of how to work with plotting characters in gnuplot.
Also, you should copy the files font.txt and readFontFile.cc from:
http://copland.udel.edu/~pconrad/cisc181h/04S/proj2/proj2
A 0,0,0 0,4,0 2,8,0 4,4,0 4,0,1 0,4,0 4,4,2 D 0,0,0 0,8,0 4,6,0 4,2,0 0,0,2 F 0,0,0 0,8,0 3,8,1 0,4,0 2,4,2 H 0,8,0 0,0,1 0,4,0 4,4,1 4,8,0 4,0,2The first character on the line is a character. The remaininder of the line consists of the points needed to draw that character. Each triple consists of an x,y,s value, where x and y are the (x,y) coordinate, and s is one of the following values:
There are 127 ASCII characters in all (see the table in Appendix B of Deitel/Deitel), and there are 14 of you. However, of these 127 characters, 31 of them are "non-printing" characters, and number 32 is the "space". So there are really only 95 characters. If you divide them up evenly, you should only have to do 6 or 7 characters each to have the entire printable 7-bit ASCII character set covered.
What you want to do next is modify this file so that it will construct an array, declared as:
// declare an array of 127 pointers, each initialized to NULL. Point *fontArray[127] = {NULL};
This array is indexed by the ASCII value of each character. As you read the data from the font.txt file, you will add pointers to linked lists into this array. For example, when you read the letter 'A' from the file, start reading each point. Allocate a struct point with:
p = new Point;and fill in the values of p->x, p->y, and p->s from the values read in from the file. Set fontArray[letter] = p. Then, as you read each successive point, add it into the linked list. You'll need to keep a pointer "tail" to point to the end of the list as you add in each point.
for (int i=1; i<argc; i++) for (int j=0; j<strlen(argv[i]); j++) { // process character in argv[i][j] }
myplot HAPPY BIRTHDAY\!will generate a myplot.dat and myplot.gnuplot file that will generate myplot.png, a file containing HAPPY BIRTHDAY!
To get an A grade, you should also allow for the case where the users passes in "-v" as the first command line parameter. If "-v" is the first command line parameter, that signifies "vertical". In this case, print the words down the page in the "on top of each other" style. For example:
myplot -v HAPPY BIRTHDAY\!should be plotted as:
HAPPY BIRTHDAY!
Note: to test your program with the "?", you will need to put a backslash on the command line. We can use the "banner" program (a unix utility) to illustarte. Try typing this at the Unix command prompt:
banner GOT MILK?You'll probably get an error message "no match". Then try:
banner GOT MILK\?
You'll have to do the same thing when you test your program with "?". Note that there is nothing special you have to do in your program to make this work; this is something the shell does for you. The "\" will be gone by the time you read the command line parameter "MILK?" out of argv[2].