Old sample.c
1 /*
2 * sample.c
3 */
4
5 /*
6 * Copyright (c) 1994-2004 Marcel J.E. Mol, The Netherlands
7 */
8
9
10 # include "mpage.h"
11
12
13 /*
14 * Function Declarations
15 */
16 static void do_sample();
17 static void urshow();
18 static void lrshow();
19 static void ulshow();
20 static void llshow();
21 static void box();
22
23 int
24 main(argc, argv)
25 int argc;
26 char **argv;
27 {
28 int currarg;
29
30 /*
31 * examine the environment for PRINTER and MPAGE environment variables
32 */
33 if ((currarg = do_env()) == 0) {
34 usage(currarg);
35 exit(1);
36 }
37
38 if ((currarg = do_args(argc, argv, 0)) < 0) {
39 usage(currarg);
40 exit(1);
41 }
42
43 do_sample();
44
45 exit(0);
46
47 } /* main */
48
49
50
51 static void
52 do_sample()
53 {
54 printf("%%!PS-mpage-layout\n");
55 printf("/Courier findfont 8 scalefont setfont\n");
56 printf("0 setlinewidth\n");
57
58 outline_8(stdout);
59
60 urshow(xbase1(), ybase1());
61 urshow(xbase1(), ybase2());
62 urshow(xbase1(), ybase3());
63 urshow(xbase1(), ybase4());
64 lrshow(xbase1(), ytop1());
65 lrshow(xbase1(), ytop2());
66 lrshow(xbase1(), ytop3());
67 lrshow(xbase1(), ytop4());
68 ulshow(xbase1()+xwid2(), ybase1());
69 ulshow(xbase1()+xwid2(), ybase2());
70 ulshow(xbase1()+xwid2(), ybase3());
71 ulshow(xbase1()+xwid2(), ybase4());
72 llshow(xbase1()+xwid2(), ytop1());
73 llshow(xbase1()+xwid2(), ytop2());
74 llshow(xbase1()+xwid2(), ytop3());
75 llshow(xbase1()+xwid2(), ytop4());
76
77 urshow(xbase2(), ybase1());
78 urshow(xbase2(), ybase2());
79 urshow(xbase2(), ybase3());
80 urshow(xbase2(), ybase4());
81 lrshow(xbase2(), ytop1());
82 lrshow(xbase2(), ytop2());
83 lrshow(xbase2(), ytop3());
84 lrshow(xbase2(), ytop4());
85 ulshow(xbase2()+xwid2(), ybase1());
86 ulshow(xbase2()+xwid2(), ybase2());
87 ulshow(xbase2()+xwid2(), ybase3());
88 ulshow(xbase2()+xwid2(), ybase4());
89 llshow(xbase2()+xwid2(), ytop1());
90 llshow(xbase2()+xwid2(), ytop2());
91 llshow(xbase2()+xwid2(), ytop3());
92 llshow(xbase2()+xwid2(), ytop4());
93 printf("showpage\n");
94
95 return;
96
97 } /* do_sample */
98
99
100
101 static void
102 urshow(int x, int y)
103 {
104
105 printf("%%- point %d,%d\n", x, y);
106 box(x, y);
107 printf("\t%d %d moveto (%d,%d) show\n", x+2, y+2, x, y);
108
109 return;
110
111 } /* urshow */
112
113
114
115 static void
116 lrshow(int x, int y)
117 {
118 printf("%%- point %d,%d\n", x, y);
119 box(x, y);
120 printf("\t%d %d moveto (%d,%d) show\n", x+2, y-6, x, y);
121
122 return;
123
124 } /* lrshow */
125
126
127
128 static void
129 ulshow(int x, int y)
130 {
131 printf("%%- point %d,%d\n", x, y);
132 box(x, y);
133 printf("\t%d %d moveto\n", x-2, y+2);
134 printf("\t(%d,%d) dup stringwidth pop -1 mul 0 rmoveto show\n", x, y);
135
136 return;
137
138 } /* ulshow */
139
140
141
142 static void
143 llshow(int x, int y)
144 {
145 printf("%%- point %d,%d\n", x, y);
146 box(x, y);
147 printf("\t%d %d moveto\n", x-2, y-6);
148 printf("\t(%d,%d) dup stringwidth pop -1 mul 0 rmoveto show\n", x, y);
149
150 return;
151
152 } /* llshow */
153
154
155
156 static void
157 box(int x, int y)
158 {
159 printf("\t%d %d moveto %d %d lineto\n", x-1, y, x+1, y);
160 printf("\t%d %d moveto %d %d lineto\n", x, y-1, x, y+1);
161 printf("\tstroke\n");
162
163 return;
164
165 } /* box */
166