Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/extras/Euro.m4

raw
1 .PS
2 #Euro.m4
3 gen_init
4 divert(-1)
5 `euro_simple([height])
6 Basic euro symbol with round outer boundary
7 default height=10pt'
8 define(`euro_simple',
9 `[ linethick = 0
10 orad = ifelse(`$1',,`5bp__',(`$1')/2)
11 u = orad/6
12 irad = orad - u
13 C: (0,0)
14 D: C+(Rect_(irad,40))
15 CD: move from C+(0,-orad) to D
16 DK: move from D down u
17 Ubot: move from C+(0,u/2) right u
18 Utop: move from Ubot.start+(0,u) right u
19 Ltop: move from C+(0,-u/2) right u
20 Lbot: move from Ltop.start+(0,-u) right u
21 L_edge: C-(7.5*u,0)
22 Start: (C,Utop)
23 slope = (CD.end.y-CD.start.y)/(CD.end.x-CD.start.x)
24 shade(0,
25 line from Start to Intersect_(Utop,CD) \
26 then to Intersect_(Ubot,CD) \
27 then to LCintersect(Ubot,C,irad)
28 arc to LCintersect(Ltop,C,irad) with .c at C
29 line to Intersect_(Ltop,CD) \
30 then to Intersect_(Lbot,CD) \
31 then to LCintersect(Lbot,C,irad)
32 arc to (D,C)-(0,D.y-C.y) with .c at C
33 line to LCintersect(DK,C,orad,R)
34 arc cw to LCintersect(Lbot,C,orad) with .c at C
35 line to (L_edge,Here) \
36 then right u/slope up u \
37 then to LCintersect(Ltop,C,orad)
38 arc cw to LCintersect(Ubot,C,orad) with .c at C
39 line to (L_edge,Here) \
40 then right u/slope up u \
41 then to LCintersect(Utop,C,orad)
42 arc cw to LCintersect(CD,C,orad,R) with .c at C
43 line to D
44 arc to LCintersect(Utop,C,irad) with .c at C
45 line to Start
46 ) ]')
47
48 `euro_symbol([ht=val; aspect=val; slant=degrees])
49 Euro symbol with variable aspect ratio and slant
50 defaults: ht=10pt, aspect=1, slant=0
51 e.g., euro_symbol(ht=14pt__; aspect=1.2)'
52
53 define(`euro_symbol',`[
54 setkey_(`$1',ht,10pt__) setkey_(`$1',aspect,1) setkey_(`$1',slant,0)
55 linethick = 0
56 orad = m4ht/2
57 u = orad/6
58 irad = orad - u
59 if m4aspect==0 then { squeeze = 1 } else { squeeze = 1/m4aspect }
60 slant = sind(m4slant)
61 C: (0,0)
62 D: C+(Rect_(irad,40))
63 CD: move from C+(0,-orad) to D
64 DK: move from D down u
65 Ubot: move from C+(0,u/2) right u
66 Utop: move from Ubot.start+(0,u) right u
67 Ltop: move from C+(0,-u/2) right u
68 Lbot: move from Ltop.start+(0,-u) right u
69 L_edge: C-(7.5*u,0)
70 Start: (C,Utop)
71 slope = (CD.end.y-CD.start.y)/(CD.end.x-CD.start.x)
72
73 shade(0,
74 S: LCintersect(Ubot,C,irad)
75 line from euro_tr(Start) to euro_tr(Intersect_(Utop,CD)) \
76 then to euro_tr(Intersect_(Ubot,CD)) \
77 then to euro_tr(S)
78 euro_arc(S,LCintersect(Ltop,C,irad),irad)
79 S: LCintersect(Lbot,C,irad)
80 line to euro_tr(Intersect_(Ltop,CD)) \
81 then to euro_tr(Intersect_(Lbot,CD)) \
82 then to euro_tr(S)
83 euro_arc(S,((D,C)-(0,D.y-C.y)),irad)
84 S: LCintersect(DK,C,orad,R)
85 line to euro_tr(S)
86 euro_arc(S,LCintersect(Lbot,C,orad),orad,cw)
87 S: LCintersect(Ltop,C,orad)
88 E: LCintersect(Lbot,C,orad)
89 line to euro_tr((L_edge,E)) \
90 then to euro_tr((L_edge,E)+(u/slope,u)) \
91 then to euro_tr(S)
92 E: LCintersect(Ubot,C,orad)
93 euro_arc(S,E,orad,cw)
94 S: LCintersect(Utop,C,orad)
95 line to euro_tr((L_edge,E)) \
96 then to euro_tr((L_edge,E)+(u/slope,u)) \
97 then to euro_tr(S)
98 euro_arc(S,LCintersect(CD,C,orad,R),orad,cw)
99 line to euro_tr(D)
100 euro_arc(D,LCintersect(Utop,C,irad),irad)
101 line to euro_tr(Start)
102 ) ]')
103
104 `aspect ratio and slant transformation'
105 define(`euro_tr',`((`$1').x*squeeze+(`$1').y*slant,(`$1').y)')
106 `transformed arc, centre C'
107 define(`euro_arc',
108 `M4X: `$1'; as = atan2(M4X.y-C.y,M4X.x-C.x)
109 M4X: `$2'; ae = atan2(M4X.y-C.y,M4X.x-C.x)
110 ifelse(`$4',cw,`if ae > as then { ae -= twopi_ }',
111 `if ae < as then { ae += twopi_ }')
112 ax = ae-as
113 n = max(5,ceiling_(abs(ax)/(10*dtor_)))
114 for i=0 to n do { P[i]: euro_tr((rect_(`$3',as+i/n*ax))) }
115 fitcurve(P,n)
116 move to P[n] ')
117
118 divert(0)dnl
119
120 euro_simple
121 move
122 euro_symbol(slant=15)
123 move
124 euro_simple(72bp__)
125 move
126 euro_symbol(ht=72bp__*2; aspect=1.0; slant=15)
127
128 .PE