-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathln03-plot
1029 lines (805 loc) · 28.9 KB
/
ln03-plot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Subject: v12i045: New version of LN03 plot(3) package
Newsgroups: comp.sources.unix
Sender: sources
Approved: [email protected]
Submitted-by: Nick Christopher <[email protected]>
Posting-number: Volume 12, Issue 45
Archive-name: ln03-plot
My ln03 plot routines are totally written by myself, save algorithms taken
from public journals. However, the driver which I had obtained from a
supposedly public domain source was, in fact AT&T software. The driver is
in fact the standard driver (with a small addition of a case to handle
boxes, which is by no means essential) and redly available to people with
who have U*IX. The routines can also be used without the driver by
linking them directly in for people who do not have the driver available.
I apologize to AT&T.
/nwc
[ It was elsie!ado who first brought it to my attention. --r$ ]
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
# Makefile
# lno.h
# order.c
# manual.txt
# ln03.man
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'Makefile'" '(324 characters)'
if test -f 'Makefile'
then
echo shar: "will not over-write existing file 'Makefile'"
else
cat << \SHAR_EOF > 'Makefile'
FILES= Makefile lno.h order.c manual.txt ln03.man
OBJECTS= drive.o order.o
LIBS= -lm
CFLAGS= -O
all: lib ln03
lib: order.o
ar cr libln03.a order.o
ln03: $(OBJECTS)
cc $(CFLAGS) $(OBJECTS) $(LIBS) -o ln03plot
order.o: lno.h
clean:
-rm -f *.o *~
package: $(FILES)
shar -cv $(FILES) > package
print:
lpr $(FILES)
SHAR_EOF
if test 324 -ne "`wc -c < 'Makefile'`"
then
echo shar: "error transmitting 'Makefile'" '(should have been 324 characters)'
fi
fi
echo shar: "extracting 'lno.h'" '(1527 characters)'
if test -f 'lno.h'
then
echo shar: "will not over-write existing file 'lno.h'"
else
cat << \SHAR_EOF > 'lno.h'
/* (C) Copyright 1986 Nicholas Christopher.
*
* lno.h
* This .h file accompanies my code, order.c, to produce graphics on sixel
* systems. If any modification are made to this code, while I am still
* employed by the Columbia University Center for Computing Activities,
* please notify me.
*
*/
#include <stdio.h>
#define MAXVERT 243 /* verticle axis (1455) div sixels (6) */
#define Xaxis 1185 /* horizontal pixel resolution */
#define Yaxis 1455 /* vertical pixzel resolution */
#define Xdec 5665 /* horizantal decipoint resolution */
#define Ydec 7235 /* vertical decipoint resolution */
#define abs(x) ((x>=0) ? (x) :-(x)) /* absolut value */
#define newcount() (count = 1) /* reset pattern count */
int cx = 0; /* memory value of x coordinate */
int cy = 0; /* memory value of y coordinate */
float xscale = 1.0; /* x axis scaling factor */
float yscale = 1.0; /* y axis scaling factor */
int xoffset = 0;
int yoffset = 0;
int mode = 1; /* flag of patern dot, solid, long, etc. */
int count = 1; /* pattern position count, dot or space? */
struct sixel {
unsigned int pixels :6; /* bit vector of the six pixels */
int horiz; /* horiz coord in sparse matrix */
struct sixel *next;
};
struct sixel *vert[MAXVERT]; /* vert spine of sparse matrix */
SHAR_EOF
if test 1527 -ne "`wc -c < 'lno.h'`"
then
echo shar: "error transmitting 'lno.h'" '(should have been 1527 characters)'
fi
fi
echo shar: "extracting 'order.c'" '(17190 characters)'
if test -f 'order.c'
then
echo shar: "will not over-write existing file 'order.c'"
else
cat << \SHAR_EOF > 'order.c'
/*
* The following code is designed to be used in conjunction with the UNIX *
* plot facilities, but may be used on its own to produce output to any *
* sixels printing system. *
* *
* If any modification are made to this code, while I am still employed by *
* the Columbia University Center for Computing Activities, please notify *
* me, [email protected]. *
* */
#include "lno.h"
#include <stdio.h>
#include <math.h>
openpl()
/* nothing really needed here */
{
}
move(x,y)
/* set cx,cy memory of last points, scale them, and clear pattern counter. */
int x,y;
{
extern int cx,cy;
newcount();
ln03scale(&x,&y);
cx = x;
cy = y;
}
cont(x,y)
/* scaled coordinates and then pass them to extend */
{
ln03scale(&x,&y);
ln03extend(x,y);
}
point(x,y)
/* scale coordinates and pass them to spot */
{
ln03scale(&x,&y);
ln03spot(x,y);
}
line(x1,y1,x2,y2)
/* mark a starting point and then simply use continue to go to second point */
int x1,y1,x2,y2;
{
move(x1,y1);
ln03scale(&x2,&y2);
ln03extend(x2,y2);
}
label(m)
/* place ascii text or math font in graph page. This is done by direct *
* decipoint location addressing. The escape codes and text if placed in *
* the output file before the sixels output. */
char *m;
{
extern int cy,cx; /* coordinates to place label */
double xx,yy,tempx,tempy;
tempx = cx;
tempy = cy;
/*next two lines convert unscaled pixel coordinates to scaled decipoints, *
*the unit the LN03 positions text by. */
xx =(Xdec * (tempx/Xaxis)) + 0.07 * tempx;
yy =Ydec - (Ydec * (tempy/Yaxis) - 0.8 * tempy);
/* If a label starts in a "~" then tell the LN03 to use its math font. *
* A non math font label can begin with a tilda, just prefix it by a space. */
if(*m == '~'){
printf("\033*>\033n\033[2 I\033[11h");
printf("\033[%d`\033[%dd%s",ln03round(xx),ln03round(yy),++m);
}
else printf("\017\033[2 I\033[11h\033[%d`\033[%dd%s",ln03round(xx),ln03round(yy),m);
cx += (strlen(m)*15);
}
arc(x,y,x1,y1,x2,y2)
/* This arc generation routine is pretty bad... I do not use it for *
* generating circles for this reason. Much of it depends on floating point *
* which, depending on the machine may not be that accurate. */
int x,y,x1,y1,x2,y2;
{
double sqrt(),temp;
register int dx,dy,radsqr;
register int plotx,ploty,quad,rad,reps = 0;
ln03scale(&x,&y);
ln03scale(&x1,&y1);
ln03scale(&x2,&y2);
dx = abs(x1-x);
dy = abs(y1-y);
radsqr = dx*dx + dy*dy;
temp = radsqr;
rad = sqrt(temp);
plotx = x1-x; /* x coord of first point in arc */
ploty = y1-y; /* y " " " " " " */
if(x1 > x+rad/2) quad = 1; /* what quadrant are we in ? */
else if(x1 > x) quad = 2;
else quad = 3;
if(y1 < y && quad == 2 ) quad = 4; /* under horizon of y is 4 not 2 */
ln03filterP(x1,y1);
while(ln03aprox(plotx+x,x2,ploty+y,y2) != 1){ /* until final coord hit, go */
if(quad == 2){ /* quadrants not standard, my are by the compass. */
plotx--; /* we are in North quadrant so inc x and calculate y */
temp = radsqr - plotx*plotx;
ploty = ln03round(sqrt(temp));
ln03extend(plotx+x,ploty+y);
if(plotx+x < x-rad/2){
quad = 3;
reps++;
}
}
else if(quad == 3){ /* in west quad, inc y and calc x */
ploty--;
temp = radsqr - ploty*ploty;
plotx =0-ln03round(sqrt(temp));
ln03extend(plotx+x,ploty+y);
if(plotx+x >= x-rad/2){
quad = 4;
reps++;
}
}
else if(quad == 4){ /* we are in south quad, mirror north*/
plotx++;
temp = radsqr - plotx*plotx;
ploty =0-ln03round(sqrt(temp));
ln03extend(plotx+x,ploty+y);
if(plotx+x > x+rad/2){
quad = 1;
reps++;
}
}
else{ /* east quad, mirror west */
ploty++;
temp = radsqr - ploty*ploty;
plotx = ln03round(sqrt(temp));
ln03extend(plotx+x,ploty+y);
if(plotx+x <= x+rad/2){
quad = 2;
reps++;
}
}
if(reps > 4) /* We have been around the circle more than once...oops! */
{
fprintf(stderr,"Second point is not in arc of center and first point.\n");
fprintf(stderr,"Bad arc is %d, %d, %d, %d, %d, %d.\n",x,y,x1,y1,x2,y2);
fprintf(stderr," Converting sparse matrix built to date and exiting.\n");
ln03conv();
exit(1);
}
}
}
circle(x,y,r)
/* this generates 45 degrees of a circle, passing each point to circpoint *
* which distributes the point to all eight 45 degree segments. */
int x,y,r;
{
register int xx,yy,d;
extern int cx,cy;
extern float xscale,yscale;
int dummy = 1;
newcount();
ln03scale(&x,&y);
r = ln03round(r * xscale);
xx = 0;
yy = r;
d = 3-2*r;
while( xx < yy){
ln03circpoint(xx,yy,x,y);
if(d < 0) d = d+4*xx+6;
else{
d = d+4*(xx-yy) + 10;
yy--;
}
xx++;
}
if(xx == yy) ln03circpoint(xx,yy,x,y);
cx = xx+x;
cy = yy+y;
}
erase()
/* Just convert what we have, and start fresh. */
{
ln03conv();
}
linemod(s)
/* set varible "mode" to reflect pattern chosen. */
char *s;
{
extern int mode;
switch(s[0]){
case 'l':
mode = 4;
break;
case 'd':
if(s[3] == 'd') mode = 5;
else mode = 2;
break;
case 's':
if(s[5] != '\0') mode = 1;
else mode = 3;
}
}
space(x1,y1,x2,y2)
/* set a scaling factor at users request. scale is defaulted to 1 */
int x1,y1,x2,y2;
{
extern float xscale,yscale;
float temp;
extern int xoffset,yoffset;
if (x1 < 0) xoffset = -x1;
if (y1 < 0) yoffset = -y1;
temp = (float)Xaxis/(x2-x1);
xscale = floor(temp * 100.0)/100.0;
temp = (float)Xaxis/(y2-y1);
yscale = floor(temp * 100.0) / 100.0;
}
closepl()
{
ln03conv();
}
/*---------------------------------------------------------------------------*/
/* BEGIN SUPPORT ROUTINES */
/*---------------------------------------------------------------------------*/
ln03extend(x1,y1)
/* Don't ask, I got this from a book, it forms a line by increment to a *
* point in the area nearest the line. negative slopes are achived by *
* mirroring a positive slope. */
register int x1,y1;
{
extern int cx,cy;
register int dx,dy,yincr1,mid,yincr2,yd,xincr1,xincr2,xd,x,y,xend,yend;
register int xx,yy;
register int neg=0;
dx = abs(x1-cx);
dy = abs(y1-cy);
yd = 2*dy-dx;
yincr1 = 2*dy;
yincr2 = 2*(dy-dx);
xd = 2*dx-dy;
xincr1 = 2*dx;
xincr2 = 2*(dx-dy);
if (cx > x1){ /* set up initial variables */
x = x1;
y = y1;
xend = cx;
yend = cy;
if(cy < y1 && cx != x1){ /* BELLS AND WISTLES negative slope */
neg = 1;
mid = y1;
yend = cy+(2*dy); /*set y to its + slope equivalent */
}
}
else
{
x = cx;
y = cy;
xend = x1;
yend = y1;
if(y1 < cy && cx != x1){ /* BELLS AND WISTLES negative slope */
neg = 1;
mid = cy;
yend = y1+(2*dy);
}
}
ln03filterP(x,y);
xx = x;
yy = y;
if (x == xend) /* we have a totally verticle line. */
while (y != yend){
if (y < yend) y++;
else y--;
ln03filterP(x,y);
}
while (x < xend){
if (yd < 0) yd += yincr1;
else{
if (y < yend) y++;
else if (y > yend) y--;
yd += yincr2;
}
if (xd < 0) xd += xincr1;
else{
x++;
xd += xincr2;
}
if (xx != x || yy != y){
if(neg) ln03filterP(x,2*mid-y);
else ln03filterP(x,y);
xx = x;
yy = y;
}
}
cx = x1; /* remember last points */
cy = y1;
}
int ln03round(num)
/* float number rounding */
double num;
{
int inum;
double rnum;
inum = num;
rnum = num - inum;
return((rnum < .5)?inum:inum+1);
}
int ln03power(z)
/* this rountine accepts an integer 0-5 and first takes its five compliment *
* then it returns 2 to the power of the result. exmp 3 = (5-3)^2 = 4 */
int z;
{
register int inc,final = 2;
z = 5-z;
if(z ==0) final = 1;
else if(z==1) final = 2;
else for(inc = 2;z >= inc; inc++) final *= 2;
return(final);
}
int ln03aprox(a,b,c,d)
/* check to see if a is aprox equal to b and if c is aprox equal to d *
* this is done because I don't trust arc's floating point to generate *
* the circumference points exactly. */
int a,b,c,d;
{
if( a <= b+1 && a >= b-1 && c <= d+1 && c >= d-1) return(1);
else return(-1);
}
death()
/* Something, some where has created an error, or we are out of RAM, *
* convert the graph as it stands. */
{
fprintf(stderr,"We have ran out of memory for sparse matrix nodes.\n");
fprintf(stderr," We will convert what has been done to date and leave.\n");
ln03conv();
exit(1);
}
ln03spot(x,y)
/* place a point given by coordinates in sparse matrix. */
int x,y;
{
extern struct sixel *vert[MAXVERT]; /* this is the plotting grid */
struct sixel *temp,*mark,*malloc();
extern int cy,cx;
register int Vval; /* verticle coordinate to the nearest sixel */
register int Svval; /* verticle coordinate, pixel remainder of sixels*/
if(x >= 0 && x <= Xaxis && y >= 0 && y <= Yaxis){
cy = y; cx = x;
Vval =(Yaxis-(y-2))/6; /* div 6 to obtain sixels */
Svval = y%6; /* modulo to obtain pixels remainder */
if(vert[Vval] == NULL){ /* this row is new, start it */
if((temp = malloc(sizeof(struct sixel)))==NULL) death();
temp->pixels = 0|(ln03power(Svval));/* calc sixels' pixel value */
temp->horiz = x;
temp->next = NULL;
vert[Vval] = temp;
}
else{ /* row already has member(s) */
mark = vert[Vval]; /* set a marker to move along list */
while(mark->next != NULL && mark->horiz < x) mark = mark->next;
/* we are now a) at row's end, b) an equal horiz, *
* c) a greater horiz. */
if(mark->next == NULL && mark->horiz < x ){
/* time to add a node because horiz is too big and no next node. */
if((temp = malloc(sizeof(struct sixel)))==NULL) death();
temp->pixels = 0|(ln03power(Svval));
temp->horiz = x;
temp->next = NULL; /* Better safe...... */
mark->next = temp; /* Add new node to vert structure. */
}
else if(mark->horiz == x) mark->pixels |= ln03power(Svval);
/* just modify this node */
else if(mark->horiz > x){
/* insert new node between two present cause we have passed its spot */
if((temp = malloc(sizeof(struct sixel)))==NULL) death();
temp->pixels = mark->pixels;
temp->horiz = mark->horiz;
temp->next = mark->next;
mark->pixels = 0|(ln03power(Svval));
mark->horiz = x;
mark->next = temp;
}
}
}
}
ln03conv()
/* This routine coverts a sparce matrix to LN03 format of sixels. The *
* size of the output is minimized by using the LN03's repeat format: *
* !10? performs ? (a space) 10 times. */
{
register int count,rep;
register int Hplace; /* horizontal displacement */
register int lastc = 0; /* sixel pixel pattern holder */
int x;
struct sixel *temp;
extern struct sixel *vert[MAXVERT]; /* sparse matrix of sixels */
/* ESC codes to get ln03 sixels mode */
printf("\033[2 I\033[1`\033[1d\033P000;0000;000q\"1;1");
for(count = 0; count < MAXVERT; count++)
if(vert[count] == NULL) printf("?-"); /* LF for a blank row */
else{
temp = vert[count];
if(temp->horiz>0) printf("!%d?",temp->horiz-1);/*tab to 1st char */
printf("%c",temp->pixels+63);
Hplace = temp->horiz;
lastc = temp->pixels;
rep = 0;
while(temp->next != NULL){
temp = temp->next; /* move one node horizontally */
if(temp->horiz == Hplace+1 && temp->pixels == lastc){
rep++;
Hplace++;
}
else{
if(rep > 0) printf("!%d%c",rep,lastc+63);
if(temp->horiz != Hplace+1 && temp->horiz <= Xaxis)
printf("!%d?",temp->horiz - Hplace - 1);
printf("%c",temp->pixels+63);
Hplace = temp->horiz;
lastc = temp->pixels;
rep = 0;
}
}
if(rep > 0) printf("!%d%c-",rep,lastc+63);
else printf("-");
}
printf("\033\\"); /* Tell ln03 we are done with sixels */
for(x = 0; x < MAXVERT; x++)
vert[x] = (struct sixel *)NULL;
}
box(x0,y0,x1,y1)
/* box drawing routine */
int x0,y0,x1,y1;
{
int xhold,yhold;
xhold = x0;
yhold = y0;
ln03scale(&x0,&y0);
ln03scale(&x1,&y1);
move(xhold,yhold);
ln03extend(x1,y0);
ln03extend(x1,y1);
move(xhold,yhold);
ln03extend(x0,y1);
ln03extend(x1,y1);
}
ln03circpoint(xx,yy,x,y)
/* circle() only calculates 45 degrees of a circle, this distributes the *
* coordinates given into an entire circle. The decrementing of count is so *
* that the position in a pattern, i.e. point or space in "dot dash" is *
* not lost. */
int xx,yy,x,y;
{
extern int cx,cy,count;
ln03filterP(xx+x,yy+y);
count--;
ln03filterP(yy+x,xx+y);
count--;
ln03filterP(yy+x,-xx+y);
count--;
ln03filterP(xx+x,-yy+y);
count--;
ln03filterP(-xx+x,-yy+y);
count--;
ln03filterP(-yy+x,-xx+y);
count--;
ln03filterP(-yy+x,xx+y);
count--;
ln03filterP(-xx+x,yy+y);
}
ln03filterP(x,y)
/* filter() acts as a middle man between a caller and spot(), i.e. if our *
* position in the line pattern (example: dotted line) is a blank space *
* then spot should not be called. */
int x,y;
{
extern int mode,count;
switch(mode){
case 1: ln03spot(x,y); /* solid line */
break;
case 2: if(count <= 3 ) ln03spot(x,y); /* dotted line */
if(count == 6) count = 0;
break;
case 3: if(count <= 6 ) ln03spot(x,y); /* short dash */
if(count == 9) count =0;
break;
case 4: if(count <= 9 ) ln03spot(x,y); /* long dash */
if(count == 12) count =0;
break;
/* dot dash */
case 5: if((count <= 6)||((count ==11)||(count==12))) ln03spot(x,y);
if(count == 17) count = 0;
break;
}
count++; /* increment pattern position. */
}
ln03scale(x,y)
int *x,*y;
{
extern float xscale,yscale;
extern int xoffset,yoffset;
int tempx,tempy;
tempx = *x;
tempy = *y;
tempx += xoffset;
tempy += yoffset;
tempx = ln03round(tempx*xscale);
tempy = ln03round(tempy*yscale);
*x = tempx;
*y = tempy;
}
SHAR_EOF
if test 17190 -ne "`wc -c < 'order.c'`"
then
echo shar: "error transmitting 'order.c'" '(should have been 17190 characters)'
fi
fi
echo shar: "extracting 'manual.txt'" '(6901 characters)'
if test -f 'manual.txt'
then
echo shar: "will not over-write existing file 'manual.txt'"
else
cat << \SHAR_EOF > 'manual.txt'
USERS GUIDE
FOR
PLOT FILTERS
David Chang
Nicholas Christopher
16 June 1987
1. INTRODUCTION TO PLOT FILTERS
The UNIX operating system has, as one of its standard libraries, a library
which produces graphics output in a device-independent manner. This output
can then be used as input for any compatible device-specific plot filter.
The plot filter generates commands, that when redirected to its
corresponding graphics device, will generate the desired graphics output.
The graphics library should be linked to your C program by using the -lplot
compiler switch.
2. COMMANDS
The subroutines that are included in the standard UNIX Plot library
are as follows:
- openpl()
Prepares the output device for taking
commands. It should always be called
before calling any other plot subroutines.
- erase()
Reinitializes the output device.
- label(s) char[s];
Places text in the output at the current
point. It takes a string variable or a string
in quotes as its argument. The argument is
null-terminated and does not contain newlines.
A local modification of the command allows the
LN03 to use its technical font. To use the LN03
technical font begin the label with a tilde
character ("~"). A space-tilde, " ~", will
allow a label in the regular font to begin
with a tilde.
- line(x1,y1,x2,y2)
Produces a line that starts at the point
designated by the first two arguments that are
passed to the subroutine and terminates at the
point designated by the final two arguments.
- circle(x,y,r)
Produces a circle whose center is given by the
first two arguments and whose radius is given
by the final argument.
- arc(x,y,x1,y1,x2,y2)
Produces an arc whose center is determined by
the first two arguments. The starting
point is given by the third and fourth
arguments and the end point is given by the
final two arguments. The arc is drawn
counter-clockwise.
- move(x,y)
Changes the current point to the point given
by the two arguments.
- cont(x,y)
Draws a point from the current point to the
point given by the two arguments.
- point(x,y)
Draws a single point at the given coordinates.
- linemod(s) char[s];
Changes the line style to the given style.
the styles that are available are `dotted',
`longdashed', `shortdashed', and `dotdashed'.
- space(x1,y1,x2,y2)
Changes the plot area, using the first two
coordinates as the upper right hand corner of
the plotting area and the final two arguments
as the lower left hand corner of the plotting
area. The plot will be reduced or magnified
to fit the device as closely as possible.
- closepl()
Closes the output device. This should always
be called at the end of your program.
There are two subroutines that have been added to the standard Plot
library here at Columbia. They are as follows:
- box(x1,y1,x2,y2)
Draws a box using the two points that are
passed as arguments as two corners. This
available on all the devices.
- color(n)
Changes the pen on a multicolor pen plotter
to the pen number designated by the argument.
This is only available on the pen plotters and
ink-jet printer.
This graphics package can be used on the Hewlett-Packard 7470A, the DEC
LVP16, the DEC LN03 laser printer, and the DEC LCP01 color ink-jet printer.
The HP 7470A is a two pen plotter. The DEC LVP16 is a six pen plotter.
Columbia has several pen plotters available at 251 Engineering Terrace and
LN03s at both the Engineering Terrace and SIA terminal room. The use of the
plotters requires your own plotter pens, which can be obtained in the Business
Office, and your own 8.5" by 11" or 11" by 17" paper.
3. SAMPLE SESSION
Below is an example program in the language C to put a round peg in a
square hole. If you are not familiar with the C language you should be warned
that it is case sensitive and so if you plan to try running the following
program maintain the capitalization exactly.
/* This is a comment */
main() /* Start of program */
{
openpl(); /* Initialize plot routines */
move(10,10); /* Position cursor */
label("Demo."); /* Text starts at cursor */
box(100,100,500,500); /* Draw a square hole */
circle(300,300,200); /* Put the round peg in */
move(10,600); /* Position cursor */
label("Done!"); /* Some more text */
closepl(); /* Close the plot routines */
}
Note that the only C in the entire program was "main() { }" the rest was
entirely plot commands. C code could have been present, to calculate a sin wave
by points for example, but knowledge of C is not required to use plot.
The above code must be compiled before it will run. Assume that the above
C program is in a file named peg.c. The command to compile C code which uses
plot commands is as follows:
cc -o peg peg.c -lplot
The above command generates the program peg can be run at any time,
however it is still not producing output for any specific printing device.
Suppose that you were sitting at a Tektronics terminal and wanted to see the
demonstration right on the screen. The command to give would be:
peg | tek
The above command takes the generalized output from peg and feeds it to
the program tek which knows how to display graphics on a Tektronics terminal
(the "|" character is called a pipe in UNIX and must be included). The tek
program then produces the graphics on your screen. The command:
peg | ln03 | lpr -Pmuddl1
Would take the same generalized output from peg feed it to ln03 a program
which creates output for the DEC LN03 printer. Then ln03 program would feeds
its output to the print command, lpr -Pmuddl1, which actually prints the given
output on the LN03 printer located in 251 Engineering Terrace.
For further documentation look in sections 1,3 and 5 of the UNIX manual
under the title plot. On a UNIX machine these manual sections can be read by
saying:
man 1 plot
man 3 plot
man 5 plot
SHAR_EOF
if test 6901 -ne "`wc -c < 'manual.txt'`"
then
echo shar: "error transmitting 'manual.txt'" '(should have been 6901 characters)'
fi
fi
echo shar: "extracting 'ln03.man'" '(661 characters)'
if test -f 'ln03.man'
then
echo shar: "will not over-write existing file 'ln03.man'"
else
cat << \SHAR_EOF > 'ln03.man'
.TH LNO3PLOT cucca
.ds SI S\s-2IX\s+2\s-2ELS\s+2
.SH NAME
ln03plot \- convert plot(5) files to S\s-2IX\s+2\s-2ELS\s+2 format
.SH SYNOPSIS
.B ln03plot
[
.I file
]
.SH DESCRIPTION
.I ln03plot