* Copyright (c) 1983 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
"@(#) Copyright (c) 1983 Regents of the University of California.\n\
static char sccsid
[] = "@(#)vplotf.c 5.4 (Berkeley) 6/30/88";
* Lpd filter to read standard graphics input and produce a plot on the
#define mapx(x) ((DevRange*((x)-botx)/del)+centx)
#define mapy(y) ((DevRange*(del-(y)+boty)/del)-centy)
static char *Sid
= "@(#)\t5/16/83";
int radius
, startx
, starty
, endx
, endy
;
int warned
= 0; /* Indicates whether the warning message about
* unimplemented routines has been printed */
int varian
; /* 0 for versatec, 1 for varian. */
int BYTES_PER_LINE
; /* number of bytes per raster line. */
int PAGE_LINES
; /* number of raster lines per page. */
int DevRange
= 1536; /* output array size (square) in pixels */
int DevRange8
= 1536/8; /* output array size in bytes */
int lines
; /* number of raster lines printed */
char zeros
[880]; /* one raster line */
char *name
, *host
, *acctfile
;
/* variables used to print from font file */
int fontSet
= 0; /* Has the font file been read */
struct dispatch dispatch
[256];
char *fontFile
= "/usr/lib/vfont/R.8";
BYTES_PER_LINE
= atoi(&argv
[0][2]) / 8;
if (varian
= BYTES_PER_LINE
== 264) {
PAGE_LINES
= atoi(&argv
[0][2]);
/* init constants for scaling */
delx
= dely
= del
= DevRange
;
centx
= (DevRange
- mapx(topx
))/2;
if ((obuf
= (char *) malloc(bufsize
= DevRange
* DevRange8
)) == NULL
) {
fprintf(stderr
, "vplotf: ran out of memory\n");
for (cp
= obuf
; cp
< arg
; )
ioctl(1, VSETSTATE
, plotmd
);
n
= BYTES_PER_LINE
- DevRange8
;
for (cp
= obuf
; cp
< arg
; cp
+= DevRange8
) {
if (write(1, cp
, DevRange8
) != DevRange8
)
if (n
&& write(1, zeros
, n
) != n
)
ioctl(1, VSETSTATE
, prtmd
);
write(1, "\n\n\n\n\n", 6);
account(name
, host
, *argv
);
account(who
, from
, acctfile
)
char *who
, *from
, *acctfile
;
if (who
== NULL
|| acctfile
== NULL
)
if (access(acctfile
, 02) || (a
= fopen(acctfile
, "a")) == NULL
)
* Varian accounting is done by 8.5 inch pages;
* Versatec accounting is by the (12 inch) foot.
fprintf(a
, "t%6.2f\t", (double)lines
/ (double)PAGE_LINES
);
for (;;) switch (x1
= getc(stdin
)) {
botx
= getinteger(stdin
);
boty
= getinteger(stdin
);
topx
= getinteger(stdin
);
topy
= getinteger(stdin
);
if (dely
/delx
> 1536./2048.)
centx
= (DevRange
- mapx(topx
))/2;
x1
= mapx(getinteger(stdin
));
y1
= mapy(getinteger(stdin
));
lastx
= mapx(getinteger(stdin
));
lasty
= mapy(getinteger(stdin
));
line(x1
, y1
, lastx
, lasty
);
x1
= mapx(getinteger(stdin
));
y1
= mapy(getinteger(stdin
));
radius
= mapx(getinteger(stdin
));
x1
= mapx(getinteger(stdin
));
y1
= mapy(getinteger(stdin
));
startx
= mapx(getinteger(stdin
));
starty
= mapy(getinteger(stdin
));
endx
= mapx(getinteger(stdin
));
endy
= mapy(getinteger(stdin
));
fprintf(stderr
,"Arcs are unimplemented\n");
lastx
= mapx(getinteger(stdin
));
lasty
= mapy(getinteger(stdin
));
while ((x1
= getc(stdin
)) != '\n')
lastx
= mapx(getinteger(stdin
));
lasty
= mapy(getinteger(stdin
));
x1
= mapx(getinteger(stdin
));
y1
= mapy(getinteger(stdin
));
line(lastx
, lasty
, x1
, y1
);
while ((x1
= getc(stdin
)) != '\n')
case 0: /* ignore null characters */
fprintf(stderr
, "Input format error %c(%o)\n",x1
,x1
);
InitFont(); /* Read font if not already read */
ptr
= bits
+ dispatch
[ch
].addr
;
for (i
= dispatch
[ch
].up
; i
> -dispatch
[ch
].down
; --i
) {
nbytes
= (dispatch
[ch
].right
+ dispatch
[ch
].left
+ 7)/8;
for (j
= 0; j
< nbytes
; j
++) {
point(lastx
+7-k
+j
*8-dispatch
[ch
].left
, lasty
-i
);
lastx
+= dispatch
[ch
].width
;
lastx
+= dispatch
['a'].width
;
if ((fonts
= open(s
, 0)) == -1) {
fprintf(stderr
, "Can't get font file");
/* Get the header and check magic number */
if (read(fonts
, &header
, sizeof(header
)) != sizeof(header
)) {
fprintf(stderr
, "Bad read in font file");
if (header
.magic
!= 0436) {
fprintf(stderr
,"Bad magic numer in font file");
if (read(fonts
, dispatch
, sizeof(dispatch
)) != sizeof(dispatch
)) {
fprintf(stderr
, "Bad read in font file");
/* Allocate space for bit map and read in bits */
bits
= (char *) malloc(header
.size
);
if (read(fonts
, bits
, header
.size
) != header
.size
) {
fprintf(stderr
,"Can't read bit map in font file");
fprintf(stderr
,"Can't close font file");
if (dx
>= dy
) while (x0
!= x1
) {
if ((x0
+slope
*y0
) & linmod
)
} else while (y0
!= y1
) {
if ((x0
+slope
*y0
) & linmod
)
if ((x1
+slope
*y1
) & linmod
)
#define labs(a) ((a) >= 0 ? (a) : -(a))
for (dy
=c
; dy
>=dx
; dy
--) {
if (labs(ep
) >= labs(ep
+de
)) {
* Points should be in the range 0 <= x (or y) <= DevRange.
* The origin is the top left-hand corner with increasing x towards the
* right and increasing y going down.
if (x
< DevRange
&& y
< DevRange
) {
byte
= y
* DevRange8
+ (x
>> 3);
obuf
[byte
] |= 1 << (7 - (x
& 07));
register int low
, high
, result
;
result
= ((high
<< 8) | low
);