| 7 |
|
|
| 8 |
|
|
| 9 |
|
#include "meta.h" |
| 10 |
– |
|
| 10 |
|
#include "plot.h" |
| 12 |
– |
|
| 11 |
|
#include "rast.h" |
| 12 |
|
|
| 13 |
|
|
| 17 |
|
|
| 18 |
|
static PRIMITIVE nextp; |
| 19 |
|
|
| 20 |
+ |
static void initplot(void); |
| 21 |
+ |
static void doglobal(PRIMITIVE *g); |
| 22 |
+ |
static void plotblock(FILE *infp); |
| 23 |
+ |
static void doprim(PRIMITIVE *p); |
| 24 |
+ |
static void doprim(PRIMITIVE *p); |
| 25 |
+ |
static void paintline(int x, int y, int run, int rise, int hrad, int vrad, |
| 26 |
+ |
int lpat, long run2, long rise2, int n); |
| 27 |
+ |
static void tfill(PRIMITIVE *p); |
| 28 |
+ |
static void fill(int attrib, int xmin, int ymin, int xmax, int ymax); |
| 29 |
|
|
| 23 |
– |
plot(infp) /* plot meta-file */ |
| 30 |
|
|
| 31 |
< |
FILE *infp; |
| 32 |
< |
|
| 31 |
> |
void |
| 32 |
> |
plot( /* plot meta-file */ |
| 33 |
> |
FILE *infp |
| 34 |
> |
) |
| 35 |
|
{ |
| 28 |
– |
|
| 36 |
|
do { |
| 37 |
|
readp(&nextp, infp); |
| 38 |
|
initplot(); |
| 41 |
|
doglobal(&nextp); |
| 42 |
|
fargs(&nextp); |
| 43 |
|
} while (nextp.com != PEOF); |
| 37 |
– |
|
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
|
| 47 |
< |
|
| 48 |
< |
|
| 43 |
< |
|
| 44 |
< |
initplot() /* initialize this plot */ |
| 45 |
< |
|
| 47 |
> |
void |
| 48 |
> |
initplot(void) /* initialize this plot */ |
| 49 |
|
{ |
| 50 |
|
int i; |
| 51 |
|
|
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
|
| 72 |
< |
|
| 73 |
< |
|
| 74 |
< |
|
| 75 |
< |
doglobal(g) /* execute a global command */ |
| 73 |
< |
|
| 74 |
< |
PRIMITIVE *g; |
| 75 |
< |
|
| 72 |
> |
void |
| 73 |
> |
doglobal( /* execute a global command */ |
| 74 |
> |
PRIMITIVE *g |
| 75 |
> |
) |
| 76 |
|
{ |
| 77 |
– |
char c; |
| 78 |
– |
int tty; |
| 79 |
– |
|
| 77 |
|
switch (g->com) { |
| 78 |
|
|
| 79 |
|
case PEOF: |
| 103 |
|
error(WARNING, errmsg); |
| 104 |
|
break; |
| 105 |
|
} |
| 109 |
– |
|
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
< |
|
| 111 |
< |
|
| 112 |
< |
plotblock(infp) /* plot next block */ |
| 113 |
< |
|
| 118 |
< |
FILE *infp; |
| 119 |
< |
|
| 110 |
> |
void |
| 111 |
> |
plotblock( /* plot next block */ |
| 112 |
> |
FILE *infp |
| 113 |
> |
) |
| 114 |
|
{ |
| 115 |
|
PLIST lastinq; |
| 116 |
|
register PRIMITIVE *p; |
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| 141 |
< |
|
| 142 |
< |
|
| 149 |
< |
nextblock() /* prepare next block */ |
| 150 |
< |
|
| 141 |
> |
extern void |
| 142 |
> |
nextblock(void) /* prepare next block */ |
| 143 |
|
{ |
| 144 |
|
register int i, n; |
| 145 |
|
register unsigned char *colp; |
| 159 |
|
outblock.ybot += NUMSCANS; |
| 160 |
|
} |
| 161 |
|
return; |
| 170 |
– |
memerr: |
| 171 |
– |
error(SYSTEM, "out of memory in nextblock"); |
| 162 |
|
} |
| 163 |
|
|
| 164 |
|
|
| 165 |
< |
|
| 166 |
< |
outputblock() /* output block to printer */ |
| 165 |
> |
void |
| 166 |
> |
outputblock(void) /* output block to printer */ |
| 167 |
|
{ |
| 168 |
|
register int i, n; |
| 169 |
|
register unsigned char *colp; |
| 181 |
|
} |
| 182 |
|
|
| 183 |
|
|
| 184 |
< |
|
| 185 |
< |
doprim(p) /* plot primitive */ |
| 186 |
< |
|
| 187 |
< |
register PRIMITIVE *p; |
| 198 |
< |
|
| 184 |
> |
void |
| 185 |
> |
doprim( /* plot primitive */ |
| 186 |
> |
register PRIMITIVE *p |
| 187 |
> |
) |
| 188 |
|
{ |
| 189 |
|
register PRIMITIVE *newp; |
| 190 |
|
|
| 218 |
|
newp->args = savestr(p->args); |
| 219 |
|
add(newp, &inqueue); |
| 220 |
|
} |
| 232 |
– |
|
| 221 |
|
} |
| 222 |
|
|
| 223 |
|
|
| 224 |
< |
|
| 225 |
< |
|
| 226 |
< |
|
| 227 |
< |
plotlseg(p) /* plot a line segment */ |
| 240 |
< |
|
| 241 |
< |
register PRIMITIVE *p; |
| 242 |
< |
|
| 224 |
> |
void |
| 225 |
> |
plotlseg( /* plot a line segment */ |
| 226 |
> |
register PRIMITIVE *p |
| 227 |
> |
) |
| 228 |
|
{ |
| 229 |
|
register int ti; |
| 230 |
|
long run2 = 0L, rise2 = 0L; |
| 282 |
|
* This routine paints a line with calls to fill(). The line can |
| 283 |
|
* start and end at arbitrary points on a longer line segment. |
| 284 |
|
*/ |
| 285 |
< |
|
| 286 |
< |
paintline(x, y, run, rise, hrad, vrad, lpat, run2, rise2, n) |
| 287 |
< |
|
| 288 |
< |
register int x, y; |
| 289 |
< |
int run, rise; |
| 290 |
< |
int hrad, vrad; |
| 291 |
< |
int lpat; |
| 292 |
< |
long run2, rise2; |
| 293 |
< |
int n; |
| 294 |
< |
|
| 285 |
> |
void |
| 286 |
> |
paintline( |
| 287 |
> |
register int x, |
| 288 |
> |
register int y, |
| 289 |
> |
int run, |
| 290 |
> |
int rise, |
| 291 |
> |
int hrad, |
| 292 |
> |
int vrad, |
| 293 |
> |
int lpat, |
| 294 |
> |
long run2, |
| 295 |
> |
long rise2, |
| 296 |
> |
int n |
| 297 |
> |
) |
| 298 |
|
{ |
| 299 |
|
int xstep, ystep; |
| 300 |
|
|
| 339 |
|
} |
| 340 |
|
|
| 341 |
|
|
| 342 |
< |
|
| 343 |
< |
tfill(p) /* fill a triangle */ |
| 344 |
< |
register PRIMITIVE *p; |
| 342 |
> |
void |
| 343 |
> |
tfill( /* fill a triangle */ |
| 344 |
> |
register PRIMITIVE *p |
| 345 |
> |
) |
| 346 |
|
{ |
| 347 |
|
register int x, txmin, txmax; |
| 348 |
|
int xmn, ymn, tpat; |
| 386 |
|
|
| 387 |
|
|
| 388 |
|
|
| 389 |
< |
|
| 390 |
< |
fill(attrib, xmin, ymin, xmax, ymax) /* fill rectangle with attribute */ |
| 391 |
< |
|
| 392 |
< |
register int attrib; |
| 393 |
< |
int xmin, ymin, xmax, ymax; |
| 394 |
< |
|
| 389 |
> |
void |
| 390 |
> |
fill( /* fill rectangle with attribute */ |
| 391 |
> |
register int attrib, |
| 392 |
> |
int xmin, |
| 393 |
> |
int ymin, |
| 394 |
> |
int xmax, |
| 395 |
> |
int ymax |
| 396 |
> |
) |
| 397 |
|
{ |
| 398 |
|
register int i, j; |
| 399 |
|
|
| 405 |
|
for (j = ymin; j <= ymax; j++) |
| 406 |
|
for (i = xmin; i <= xmax; i++) |
| 407 |
|
if (pattern[(attrib&074)>>2] |
| 408 |
< |
[(j>>3)%(PATSIZE>>3)][i%PATSIZE] & 1<<(j&07)) |
| 408 |
> |
[(j>>3)%(PATSIZE>>3)][i%PATSIZE] & 1<<(j&07)) { |
| 409 |
|
|
| 410 |
|
if (attrib & 0100) { |
| 411 |
|
pixtog(i,j,attrib&03); |
| 412 |
|
} else { |
| 413 |
|
pixmix(i,j,attrib&03); |
| 414 |
|
} |
| 415 |
+ |
} |
| 416 |
|
|
| 417 |
|
} |