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
20 PROTO((floatish *x, floatish *y, floatish *py, floatish shade));
27 for (i = 0; i < nidents; i++) {
33 * Draw a curve, and fill the area that is below it and above
44 for (ch = e->chk; ch; ch = ch->next) {
45 for (j = 0; j < ch->nd; j++) {
46 y[ ch->d[j].bucket ] += ch->d[j].value;
50 ShadeCurve(x, y, py, ShadeOf(e->name));
54 static void PlotCurveLeftToRight PROTO((floatish *, floatish *)); /* forward */
55 static void PlotCurveRightToLeft PROTO((floatish *, floatish *)); /* forward */
57 static void SaveCurve PROTO((floatish *, floatish *)); /* forward */
60 * Map virtual x coord to physical x coord
73 * Map virtual y coord to physical y coord
85 * Fill the region bounded by two splines, using the given
90 ShadeCurve(x, y, py, shade)
91 floatish *x; floatish *y; floatish *py; floatish shade;
93 fprintf(psfp, "%f %f moveto\n", xpage(x[0]), ypage(py[0]));
94 PlotCurveLeftToRight(x, py);
96 fprintf(psfp, "%f %f lineto\n", xpage(x[nsamples - 1]),
97 ypage(y[nsamples - 1]));
98 PlotCurveRightToLeft(x, y);
100 fprintf(psfp, "closepath\n");
102 fprintf(psfp, "gsave\n");
105 fprintf(psfp, "fill\n");
107 fprintf(psfp, "grestore\n");
108 fprintf(psfp, "stroke\n");
114 PlotCurveLeftToRight(x,y)
115 floatish *x; floatish *y;
119 for (i = 0; i < nsamples; i++) {
120 fprintf(psfp, "%f %f lineto\n", xpage(x[i]), ypage(y[i]));
125 PlotCurveRightToLeft(x,y)
126 floatish *x; floatish *y;
130 for (i = nsamples - 1; i >= 0; i-- ) {
131 fprintf(psfp, "%f %f lineto\n", xpage(x[i]), ypage(y[i]));
136 * Save the curve coordinates stored in y[] in py[].
141 floatish *y; floatish* py;
145 for (i = 0; i < nsamples; i++) {
150 extern floatish xrange;
157 x = (floatish*) xmalloc(nsamples * sizeof(floatish));
158 y = (floatish*) xmalloc(nsamples * sizeof(floatish));
159 py = (floatish*) xmalloc(nsamples * sizeof(floatish));
161 for (i = 0; i < nsamples; i++) {
162 x[i] = ((samplemap[i] - samplemap[0])/ xrange) * graphwidth;