--- ray/src/meta/rplot.c 2003/02/22 02:07:26 1.1 +++ ray/src/meta/rplot.c 2019/11/18 22:12:32 1.4 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rplot.c,v 1.1 2003/02/22 02:07:26 greg Exp $"; +static const char RCSid[] = "$Id: rplot.c,v 1.4 2019/11/18 22:12:32 greg Exp $"; #endif /* * Plotting routines for meta-files to raster files @@ -7,9 +7,7 @@ static const char RCSid[] = "$Id: rplot.c,v 1.1 2003/0 #include "meta.h" - #include "plot.h" - #include "rast.h" @@ -19,13 +17,22 @@ static PLIST inqueue = {NULL, NULL}; static PRIMITIVE nextp; +static void initplot(void); +static void doglobal(PRIMITIVE *g); +static void plotblock(FILE *infp); +static void doprim(PRIMITIVE *p); +static void doprim(PRIMITIVE *p); +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 tfill(PRIMITIVE *p); +static void fill(int attrib, int xmin, int ymin, int xmax, int ymax); -plot(infp) /* plot meta-file */ -FILE *infp; - +void +plot( /* plot meta-file */ + FILE *infp +) { - do { readp(&nextp, infp); initplot(); @@ -34,15 +41,11 @@ FILE *infp; doglobal(&nextp); fargs(&nextp); } while (nextp.com != PEOF); - } - - - -initplot() /* initialize this plot */ - +void +initplot(void) /* initialize this plot */ { int i; @@ -50,14 +53,14 @@ initplot() /* initialize this plot */ /* allocate block */ if (outblock.xright <= 0) { for (i = 0; i < NUMSCANS; i++) - if ((outblock.cols[i] = (unsigned char *)malloc(dxsize)) == NULL) + if ((outblock.cols[i] = (unsigned char *)malloc(dxsiz)) == NULL) error(SYSTEM, "out of memory in initplot"); } outblock.xleft = 0; - outblock.xright = dxsize-1; + outblock.xright = dxsiz-1; if (ydown) { - outblock.ytop = dysize+NUMSCANS-1; - outblock.ybot = dysize; + outblock.ytop = dysiz+NUMSCANS-1; + outblock.ybot = dysiz; } else { outblock.ytop = -1; outblock.ybot = -NUMSCANS; @@ -66,17 +69,11 @@ initplot() /* initialize this plot */ } - - - -doglobal(g) /* execute a global command */ - -PRIMITIVE *g; - +void +doglobal( /* execute a global command */ + PRIMITIVE *g +) { - char c; - int tty; - switch (g->com) { case PEOF: @@ -106,17 +103,14 @@ PRIMITIVE *g; error(WARNING, errmsg); break; } - } - - -plotblock(infp) /* plot next block */ - -FILE *infp; - +void +plotblock( /* plot next block */ + FILE *infp +) { PLIST lastinq; register PRIMITIVE *p; @@ -144,17 +138,15 @@ FILE *infp; - - -nextblock() /* prepare next block */ - +extern void +nextblock(void) /* prepare next block */ { register int i, n; register unsigned char *colp; /* clear block */ for (i = 0; i < NUMSCANS; i++) { colp = outblock.cols[i]; - n = dxsize; + n = dxsiz; while (n--) *colp++ = IWHT<<3 | IWHT; } @@ -167,13 +159,11 @@ nextblock() /* prepare next block */ outblock.ybot += NUMSCANS; } return; -memerr: - error(SYSTEM, "out of memory in nextblock"); } - -outputblock() /* output block to printer */ +void +outputblock(void) /* output block to printer */ { register int i, n; register unsigned char *colp; @@ -191,11 +181,10 @@ outputblock() /* output block to printer */ } - -doprim(p) /* plot primitive */ - -register PRIMITIVE *p; - +void +doprim( /* plot primitive */ + register PRIMITIVE *p +) { register PRIMITIVE *newp; @@ -207,9 +196,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: @@ -229,17 +218,13 @@ register PRIMITIVE *p; newp->args = savestr(p->args); add(newp, &inqueue); } - } - - - -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; @@ -253,17 +238,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); @@ -297,16 +282,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; @@ -351,18 +339,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 = (outblock.ybot - ymn)*xsz/ysz; @@ -397,12 +386,14 @@ register PRIMITIVE *p; - -fill(attrib, xmin, ymin, xmax, ymax) /* fill rectangle with attribute */ - -register int attrib; -int xmin, ymin, xmax, ymax; - +void +fill( /* fill rectangle with attribute */ + register int attrib, + int xmin, + int ymin, + int xmax, + int ymax +) { register int i, j; @@ -414,12 +405,13 @@ int xmin, ymin, xmax, ymax; for (j = ymin; j <= ymax; j++) for (i = xmin; i <= xmax; i++) if (pattern[(attrib&074)>>2] - [(j>>3)%(PATSIZE>>3)][i%PATSIZE] & 1<<(j&07)) + [(j>>3)%(PATSIZE>>3)][i%PATSIZE] & 1<<(j&07)) { if (attrib & 0100) { pixtog(i,j,attrib&03); } else { pixmix(i,j,attrib&03); } + } }