summaryrefslogtreecommitdiff
path: root/metapost/context/base/mpiv/mp-symb.mpiv
blob: 40681adf171dbcda5914e87f42e5db949b4552c3 (plain)
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
%D \module
%D   [       file=mp-symb.mp,
%D        version=very old,
%D          title=\CONTEXT\ \METAPOST\ graphics,
%D       subtitle=navigation symbol macros,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D Instead of these symbols, you can use the \type {contnav}
%D font by Taco Hoekwater that is derived form this file.

u  := 3;
h  := 5u;
wt := 5u;
wb := .25wt;
o  := .1u;
pw := .5u;

drawoptions (withpen pencircle scaled pw);

path lefttriangle, righttriangle, sublefttriangle, subrighttriangle;

pair s ; s = (2wb,0) ;

x1t = x2t = 0;
x3t = wt;
y3t = .5h;
z1t-z2t = (z3t-z2t) rotated 60;

z4t = (z2t--z3t) intersectionpoint ((z1t--z2t) shifted s) ;
z5t = (z3t--z1t) intersectionpoint ((z1t--z2t) shifted s) ;

righttriangle = z1t--z2t--z3t--cycle;
lefttriangle = righttriangle rotatedaround((0,.5h), 180) shifted (wt,0);

subrighttriangle = z4t--((z2t--z3t--z1t) shifted s)--z5t ;
sublefttriangle  = subrighttriangle rotatedaround((0,.5h), 180) shifted (wt,0);

path sidebar;

x1b = x4b = 0;
x2b = x3b = wb;
y1b = y2b = y1t;
y3b = y4b = y2t;

sidebar = z1b--z2b--z3b--z4b--cycle;

path midbar, onebar, twobar;

hh = abs(y1t-y2t);

%midbar := unitsquare scaled 2hh/3;
midbar := unitsquare scaled hh;
onebar := unitsquare xscaled (hh/3) yscaled hh;
twobar := onebar;

def prepareglyph =
  drawoptions (withpen pencircle scaled .5u);
enddef;

def finishglyph =
  set_outer_boundingbox currentpicture;
  bboxmargin := o;
  setbounds currentpicture to bbox currentpicture;
%  draw boundingbox currentpicture withcolor red withpen pencircle scaled 1;
enddef;

beginfig  (1);
  prepareglyph;
  fill lefttriangle;
  draw lefttriangle;  % draw gets the bbox right, filldraw doesn't
  finishglyph;
endfig;

beginfig  (2);
  prepareglyph;
  fill righttriangle;
  draw righttriangle;
  finishglyph;
endfig;

beginfig  (3);
  prepareglyph;
  fill sidebar;
  draw sidebar;
  fill lefttriangle shifted (.5s);
  draw lefttriangle shifted (.5s);
  finishglyph;
endfig;

beginfig  (4);
  prepareglyph;
  fill righttriangle;
  draw righttriangle;
  fill sidebar shifted (wt,0);
  draw sidebar shifted (wt,0);
  finishglyph;
endfig;

beginfig  (5);
  prepareglyph;
  fill lefttriangle;
  draw lefttriangle;
  fill lefttriangle shifted s;
  draw lefttriangle shifted s;
  finishglyph;
endfig;

beginfig  (6);
  prepareglyph;
  fill righttriangle;
  draw righttriangle;
  fill righttriangle shifted s;
  draw righttriangle shifted s;
  finishglyph;
endfig;

beginfig  (7);
  prepareglyph;
  fill midbar;
  draw midbar;
  finishglyph;
endfig;

beginfig  (8);
  prepareglyph;
  fill onebar;
  draw onebar;
  finishglyph;
endfig;

beginfig  (9);
  prepareglyph;
  fill twobar;
  draw twobar;
  fill twobar shifted (pw+hh/2,0);
  draw twobar shifted (pw+hh/2,0);
  finishglyph;
endfig;

beginfig(101);
  prepareglyph;
  draw lefttriangle;
  finishglyph;
endfig;

beginfig(102);
  prepareglyph;
  draw righttriangle;
  finishglyph;
endfig;

beginfig(103);
  prepareglyph;
  draw sidebar;
  draw lefttriangle shifted (.5s);
  finishglyph;
endfig;

beginfig(104);
  prepareglyph;
  draw righttriangle;
  draw sidebar shifted (wt,0);
  finishglyph;
endfig;

beginfig(105);
  prepareglyph;
  draw lefttriangle;
  draw lefttriangle shifted s;
  finishglyph;
endfig;

beginfig(106);
  prepareglyph;
  draw righttriangle;
  draw righttriangle shifted s;
  finishglyph;
endfig;

beginfig(107);
  prepareglyph;
  draw midbar;
  finishglyph;
endfig;

beginfig(108);
  prepareglyph;
  draw onebar;
  finishglyph;
endfig;

beginfig(109);
  prepareglyph;
  draw twobar;
  draw twobar shifted (pw+hh/2,0);
  finishglyph;
endfig;

beginfig(201);
  prepareglyph;
  draw lefttriangle;
  finishglyph;
endfig;

beginfig(202);
  prepareglyph;
  draw righttriangle;
  finishglyph;
endfig;

beginfig(203);
  prepareglyph;
  draw sidebar;
  draw lefttriangle shifted (.5s);
  finishglyph;
endfig;

beginfig(204);
  prepareglyph;
  draw righttriangle;
  draw sidebar shifted (wt,0);
  finishglyph;
endfig;

beginfig(205);
  prepareglyph;
  draw sublefttriangle shifted s;
  draw lefttriangle shifted s;
  finishglyph;
endfig;

beginfig(206);
  prepareglyph;
  draw subrighttriangle;
  draw righttriangle;
  finishglyph;
endfig;

beginfig(207);
  prepareglyph;
  draw midbar;
  finishglyph;
endfig;

beginfig(208);
  prepareglyph;
  draw onebar;
  finishglyph;
endfig;

beginfig(209);
  prepareglyph;
  draw twobar;
  draw twobar shifted (pw+hh/2,0);
  finishglyph;
endfig;


beginfig(999);

picture collection []  ;

prepareglyph ;
draw lefttriangle ;
finishglyph ;
collection[201] := currentpicture ;
currentpicture := nullpicture ;

prepareglyph ;
draw righttriangle ;
finishglyph ;
collection[202] := currentpicture ;
currentpicture := nullpicture ;

prepareglyph ;
draw sidebar ;
draw lefttriangle shifted (.5s) ;
finishglyph ;
collection[203] := currentpicture ;
currentpicture := nullpicture ;

prepareglyph ;
draw righttriangle ;
draw sidebar shifted (wt,0) ;
finishglyph ;
collection[204] := currentpicture ;
currentpicture := nullpicture ;

prepareglyph ;
draw sublefttriangle shifted s ;
draw lefttriangle shifted s ;
finishglyph ;
collection[205] := currentpicture ;
currentpicture := nullpicture ;

prepareglyph ;
draw subrighttriangle ;
draw righttriangle ;
finishglyph ;
collection[206] := currentpicture ;
currentpicture := nullpicture ;

prepareglyph ;
draw midbar ;
finishglyph ;
collection[207] := currentpicture ;
currentpicture := nullpicture ;

prepareglyph ;
draw onebar ;
finishglyph ;
collection[208] := currentpicture ;
currentpicture := nullpicture ;

prepareglyph ;
draw twobar ;
draw twobar shifted (pw+hh/2,0) ;
finishglyph ;
collection[209] := currentpicture ;
currentpicture := nullpicture ;

for i=201 upto 209 :
  collection[i] := collection[i] shifted - center collection[i] ;
endfor ;

addto currentpicture also collection[205] shifted (   0,   0)
  withcolor (.3,.4,.5) ;
addto currentpicture also collection[202] shifted (   0,1.5h)
  withcolor (.5,.6,.7) ;
addto currentpicture also collection[201] shifted (1.5h,   0)
  withcolor (.6,.7,.8) ;
addto currentpicture also collection[206] shifted (1.5h,1.5h)
  withcolor (.4,.5,.6) ;

collection[210] := currentpicture ;
currentpicture := nullpicture ;

bboxmargin := .25u;

fill bbox collection[210] withcolor .95(1,1,0);
addto currentpicture also collection[210] ;

endfig ;

end