Debian Codegraph @

texmf-dist/fonts/source/public/feyn/feynmac.mf

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %
3 % Macros to support feyn.mf
4 % Release 0.4.3, 2022 July 20
5
6
7 def looselink = ..tension 0.75.. enddef;
8 def pen = pickup diagram_pen enddef;
9
10 numeric nn;
11 def dirlooselink(expr point,rtn) =
12 looselink{(-point) rotated (90-rtn)}point enddef;
13
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15 %
16 % Draw three related characters, one plain, one with an right-pointing
17 % arrow, and one with a left-pointing one, at basechar, basechar-0x20 and
18 % basechar-0x60.
19 def threechars(expr basechar, name, cp, apoint, wsharp, hsharp, dsharp, anudge, apos) =
20 % basechar : the charcode of the character in the lowercase range
21 % name : the name of the character
22 % cp : the path to be drawn
23 % apoint : the point along the path where arrow and annotation are to go
24 % wsharp, hsharp, dsharp : the sharped dimensions of the character
25 % anudge : if a pair, the offset from (point apoint of cp) where
26 % the annotation is to go (usually numeric 0, indicating
27 % no offset)
28 % apos : one of the apos arguments to annotate_at
29 beginchar (basechar, wsharp, hsharp, dsharp);
30 name;
31 pen;
32 draw cp;
33 annotate_at(point apoint of cp if (pair anudge): shifted anudge fi,
34 apos);
35 endchar;
36 beginchar (byte basechar-hex"20", wsharp, hsharp, dsharp);
37 "r-arrowed " & name;
38 pen;
39 draw cp;
40 drawarrow (littlearrow,
41 point apoint of cp,
42 angle(direction apoint of cp));
43 annotate_at(point apoint of cp if (pair anudge): shifted anudge fi,
44 apos);
45 endchar;
46 beginchar (byte basechar-hex"60", wsharp, hsharp, dsharp);
47 "l-arrowed " & name;
48 pen;
49 draw cp;
50 drawarrow (littlearrow,
51 point apoint of cp,
52 angle(direction apoint of cp) + 180);
53 annotate_at(point apoint of cp if (pair anudge): shifted anudge fi,
54 apos);
55 endchar;
56 enddef;
57
58
59 % Writes on the log file a string consisting of
60 % annotate charcode xofs yofs apos
61 % where charcode is the current character code, and xofs and yofs are the
62 % positions of the given point, relative to the reference point, in units
63 % of the font module. The string apos is one of top, bot, urt, ulft, lrt,
64 % llft, to indicate where the annotation is to sit, relative to the
65 % indicated position.
66 %
67 % Must be called within beginchar()...endchar;
68 def annotate_at (expr p, apos) =
69 message "annotate " & decimal charcode & " " &
70 decimal (xpart p/module) & " " & decimal (ypart p/module) & " "
71 & apos & " ";
72 enddef;
73
74 % Draw an arrow.
75 def drawarrow (expr size, pos, ang) =
76 % size : the scale of the arrow
77 % pos : the position of the arrow, relative to the reference point
78 % ang : the direction in which the arrow points
79 begingroup
80 pair t[];
81 y0 = y1 = y4 = 0;
82 x1 = -4x4 = -2x2 = size;
83
84 x2 = x3 = x0;
85 y2 - y0 = y0 - y3 = size/2;
86
87 forsuffixes s = 1,2,3,4 :
88 t[s] := z[s] rotated ang shifted pos;
89 endfor;
90 fill t4--t2--t1--t3--cycle;
91
92 endgroup
93 enddef;
94
95 def garrow (expr code, ang, onaxis) =
96 numeric localarrowsize;
97 % if onaxis = 1 :
98 % localarrowsize := bigarrow;
99 % else :
100 localarrowsize := littlearrow;
101 % fi
102
103 beginchar (code, 0, 0, 0); "garrow";
104 drawarrow (localarrowsize, (0, onaxis*a), ang);
105 endchar;
106 enddef;
107
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109 %
110 % Error character.
111 %
112 % The parameter ht is the nominal height of the character.
113 def errorchar (expr ht) =
114 begingroup
115 numeric rad,npetals,ilowest;
116 pair cent;
117 cent=(0,2ht/3); % centre of the flower
118 rad=ht/6; % radius of the inner points
119 npetals=5; % number of petals
120 pickup pencircle scaled (thinlinewidth); % thin line
121 z0 = cent shifted (rad,0);
122 for i=1 upto npetals-1:
123 z[i] = z0 rotatedabout (cent, i*360/npetals);
124 endfor
125 draw z0{dir 0}
126 for i=1 upto npetals-1:
127 .. tension 0.75 ..{dir (i*360/npetals+180)}z[i]{dir (i*360/npetals)}
128 endfor
129 ..{dir 180}z0;
130 ilowest := 0;
131 for i=1 upto npetals-1:
132 if y[i] <= y[ilowest]: ilowest := i; fi
133 endfor
134 draw z[ilowest]{dir (ilowest*360/npetals)}..origin;
135 pair leafend;
136 xpart(leafend) = 3rad; % want something like currentpicture.rt;
137 ypart(leafend) = 2y[ilowest]/3;
138 draw origin{dir 60} .. leafend;
139 draw leafend .. {dir 180}origin;
140 endgroup
141 enddef;