--- ray/src/meta/mplot.c 2003/02/22 02:07:26 1.1 +++ ray/src/meta/mplot.c 2019/11/18 22:12:32 1.4 @@ -1,17 +1,18 @@ #ifndef lint -static const char RCSid[] = "$Id: mplot.c,v 1.1 2003/02/22 02:07:26 greg Exp $"; +static const char RCSid[] = "$Id: mplot.c,v 1.4 2019/11/18 22:12:32 greg Exp $"; #endif /* * Plotting routines for meta-files to line-at-a-time printers */ +#include +#include #include +#include "platform.h" #include "meta.h" - #include "plot.h" - #include "span.h" @@ -22,12 +23,22 @@ static PLIST inqueue = {NULL, NULL}; static PRIMITIVE nextp; +static void initplot(void); +static void plotspan(FILE *infp); +static void doglobal(PRIMITIVE *g); +static void doprim(PRIMITIVE *p); +static void outputspan(void); +static void tfill(PRIMITIVE *p); +static void fill(int attrib, int xmin, int ymin, int xmax, int ymax); +static void paintline(int x, int y, int run, int rise, int hrad, int vrad, + int lpat, long run2, long rise2, int n); +static void nextspan(void); -plot(infp) /* plot meta-file */ - -FILE *infp; - +void +plot( /* plot meta-file */ + FILE *infp +) { do { @@ -42,29 +53,23 @@ FILE *infp; } - - - -initplot() /* initialize this plot */ - +void +initplot(void) /* initialize this plot */ { - thispage(); outspan.xleft = 0; - outspan.xright = dxsize - 1; - outspan.ytop = dysize + linhite - 1; - outspan.ybot = dysize; + outspan.xright = dxsiz - 1; + outspan.ytop = dysiz + linhite - 1; + outspan.ybot = dysiz; } - - -doglobal(g) /* execute a global command */ - -PRIMITIVE *g; - +void +doglobal( /* execute a global command */ + PRIMITIVE *g +) { char c; int tty; @@ -87,7 +92,7 @@ PRIMITIVE *g; error(USER, "illegal continue direction in doglobal"); break; - case PPAUSE: + case PPAUS: fflush(stdout); tty = open(TTY, O_RDWR); if (g->args != NULL) { @@ -124,12 +129,10 @@ PRIMITIVE *g; - - -plotspan(infp) /* plot next span */ - -FILE *infp; - +void +plotspan( /* plot next span */ + FILE *infp +) { PLIST lastinq; register PRIMITIVE *p; @@ -145,7 +148,7 @@ FILE *infp; pfree(p); } /* plot from file */ - while (isprim(nextp.com) && CONV(nextp.xy[YMX],dysize) >= outspan.ybot) { + while (isprim(nextp.com) && CONV(nextp.xy[YMX],dysiz) >= outspan.ybot) { doprim(&nextp); fargs(&nextp); readp(&nextp, infp); @@ -156,18 +159,15 @@ FILE *infp; } - - - -nextspan() /* prepare next span */ - +void +nextspan(void) /* prepare next span */ { register int i; register char *colp, *tcolp; if (spanmin <= spanmax) { /* clear span */ - i = nrows*dxsize; + i = nrows*dxsiz; colp = outspan.cols; tcolp = outspan.tcols; while (i--) @@ -176,21 +176,21 @@ nextspan() /* prepare next span */ outspan.ytop -= linhite; /* advance to next */ outspan.ybot -= linhite; - spanmin = dxsize; + spanmin = dxsiz; spanmax = 0; } - -outputspan() /* output span to printer */ +void +outputspan(void) /* output span to printer */ { register int i; register char *colp, *tcolp; if (spanmin <= spanmax) { /* overlay spans */ - i = nrows*dxsize; + i = nrows*dxsiz; colp = outspan.cols; tcolp = outspan.tcols; while (i--) @@ -200,11 +200,10 @@ outputspan() /* output span to printer */ } - -doprim(p) /* plot primitive */ - -register PRIMITIVE *p; - +void +doprim( /* plot primitive */ +register PRIMITIVE *p +) { register PRIMITIVE *newp; @@ -216,9 +215,9 @@ register PRIMITIVE *p; case PRFILL: fill((p->arg0&0103) | (pati[(p->arg0>>2)&03]<<2), - CONV(p->xy[XMN],dxsize),CONV(p->xy[YMN],dysize), - CONV(p->xy[XMX],dxsize)+(p->arg0&0100?-1:0), - CONV(p->xy[YMX],dysize)+(p->arg0&0100?-1:0)); + CONV(p->xy[XMN],dxsiz),CONV(p->xy[YMN],dysiz), + CONV(p->xy[XMX],dxsiz)+(p->arg0&0100?-1:0), + CONV(p->xy[YMX],dysiz)+(p->arg0&0100?-1:0)); break; case PTFILL: @@ -235,7 +234,7 @@ register PRIMITIVE *p; return; } - if (CONV(p->xy[YMN],dysize) < outspan.ybot) { /* save for next time */ + if (CONV(p->xy[YMN],dysiz) < outspan.ybot) { /* save for next time */ if ((newp = palloc()) == NULL) error(SYSTEM, "memory limit exceeded in doprim"); mcopy((char *)newp, (char *)p, sizeof(PRIMITIVE)); @@ -247,12 +246,10 @@ register PRIMITIVE *p; - - -plotlseg(p) /* plot a line segment */ - -register PRIMITIVE *p; - +void +plotlseg( /* plot a line segment */ + register PRIMITIVE *p +) { register int ti; long run2 = 0L, rise2 = 0L; @@ -266,17 +263,17 @@ register PRIMITIVE *p; ti = (p->arg0 >> 2) & 03; /* compute line radius */ ti = WIDTH(ti) / 2; - hrad = CONV(ti, dxsize); - vrad = CONV(ti, dysize); + hrad = CONV(ti, dxsiz); + vrad = CONV(ti, dysiz); if (hrad < minwidth) hrad = minwidth; if (vrad < minwidth) vrad = minwidth; - x = CONV(p->xy[XMX], dxsize); /* start at top */ - y = CONV(p->xy[YMX], dysize); - run = CONV(p->xy[XMN], dxsize) - x; - rise = CONV(p->xy[YMN], dysize) - y; + x = CONV(p->xy[XMX], dxsiz); /* start at top */ + y = CONV(p->xy[YMX], dysiz); + run = CONV(p->xy[XMN], dxsiz) - x; + rise = CONV(p->xy[YMN], dysiz) - y; if (p->arg0 & 0100) /* slope < 0; reverse x */ x -= (run = -run); @@ -310,16 +307,19 @@ register PRIMITIVE *p; * This routine paints a line with calls to fill(). The line can * start and end at arbitrary points on a longer line segment. */ - -paintline(x, y, run, rise, hrad, vrad, lpat, run2, rise2, n) - -register int x, y; -int run, rise; -int hrad, vrad; -int lpat; -long run2, rise2; -int n; - +void +paintline( + register int x, + register int y, + int run, + int rise, + int hrad, + int vrad, + int lpat, + long run2, + long rise2, + int n +) { int xstep, ystep; @@ -364,18 +364,19 @@ int n; } - -tfill(p) /* fill a triangle */ -register PRIMITIVE *p; +void +tfill( /* fill a triangle */ + register PRIMITIVE *p +) { register int x, txmin, txmax; int xmn, ymn, tpat; long xsz, ysz; - xmn = CONV(p->xy[XMN], dxsize); - xsz = CONV(p->xy[XMX], dxsize) - xmn; - ymn = CONV(p->xy[YMN], dysize); - ysz = CONV(p->xy[YMX], dysize) - ymn; + xmn = CONV(p->xy[XMN], dxsiz); + xsz = CONV(p->xy[XMX], dxsiz) - xmn; + ymn = CONV(p->xy[YMN], dysiz); + ysz = CONV(p->xy[YMX], dysiz) - ymn; if (xsz <= 0 || ysz <= 0) return; txmin = (outspan.ybot - ymn)*xsz/ysz; @@ -410,12 +411,14 @@ register PRIMITIVE *p; - -fill(attrib, xmin, ymin, xmax, ymax) /* fill rectangle with attribute */ - -int attrib; -int xmin, ymin, xmax, ymax; - +void +fill( /* fill rectangle with attribute */ + int attrib, + int xmin, + int ymin, + int xmax, + int ymax +) { int filpat; int rpos; @@ -446,11 +449,11 @@ int xmin, ymin, xmax, ymax; [((outspan.ybot>>3)+rpos)%(PATSIZE>>3)]; if (attrib & 0100) { - colp = &outspan.tcols[rpos*dxsize + xmin]; + colp = &outspan.tcols[rpos*dxsiz + xmin]; for (i = xmin; i <= xmax; i++) *colp++ ^= filpat & pattr[i%PATSIZE]; } else { - colp = &outspan.cols[rpos*dxsize + xmin]; + colp = &outspan.cols[rpos*dxsiz + xmin]; for (i = xmin; i <= xmax; i++) *colp++ |= filpat & pattr[i%PATSIZE]; }