5 #include "Dimensions.h"
13 static floatish *x; /* x and y values */
16 static floatish *py; /* previous y values */
18 static void Curve PROTO((struct entry *)); /* forward */
19 static void ShadeCurve(); /* forward */
26 for (i = 0; i < nidents; i++) {
32 * Draw a curve, and fill the area that is below it and above
43 for (ch = e->chk; ch; ch = ch->next) {
44 for (j = 0; j < ch->nd; j++) {
45 y[ ch->d[j].bucket ] += ch->d[j].value;
49 ShadeCurve(x, y, py, ShadeOf(e->name));
53 static void PlotCurveLeftToRight PROTO((floatish *, floatish *)); /* forward */
54 static void PlotCurveRightToLeft PROTO((floatish *, floatish *)); /* forward */
56 static void SaveCurve PROTO((floatish *, floatish *)); /* forward */
59 * Map virtual x coord to physical x coord
72 * Map virtual y coord to physical y coord
84 * Fill the region bounded by two splines, using the given
89 ShadeCurve(x, y, py, shade)
90 floatish *x; floatish *y; floatish *py; floatish shade;
92 fprintf(psfp, "%f %f moveto\n", xpage(x[0]), ypage(py[0]));
93 PlotCurveLeftToRight(x, py);
95 fprintf(psfp, "%f %f lineto\n", xpage(x[nsamples - 1]),
96 ypage(y[nsamples - 1]));
97 PlotCurveRightToLeft(x, y);
99 fprintf(psfp, "closepath\n");
101 fprintf(psfp, "gsave\n");
104 fprintf(psfp, "fill\n");
106 fprintf(psfp, "grestore\n");
107 fprintf(psfp, "stroke\n");
113 PlotCurveLeftToRight(x,y)
114 floatish *x; floatish *y;
118 for (i = 0; i < nsamples; i++) {
119 fprintf(psfp, "%f %f lineto\n", xpage(x[i]), ypage(y[i]));
124 PlotCurveRightToLeft(x,y)
125 floatish *x; floatish *y;
129 for (i = nsamples - 1; i >= 0; i-- ) {
130 fprintf(psfp, "%f %f lineto\n", xpage(x[i]), ypage(y[i]));
135 * Save the curve coordinates stored in y[] in py[].
140 floatish *y; floatish* py;
144 for (i = 0; i < nsamples; i++) {
149 extern floatish xrange;
156 x = (floatish*) xmalloc(nsamples * sizeof(floatish));
157 y = (floatish*) xmalloc(nsamples * sizeof(floatish));
158 py = (floatish*) xmalloc(nsamples * sizeof(floatish));
160 for (i = 0; i < nsamples; i++) {
161 x[i] = ((samplemap[i] - samplemap[0])/ xrange) * graphwidth;