Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/recycle.m4

raw
1 .PS
2 # recycle.m4
3 gen_init
4 NeedDpicTools
5 [
6 # Gradient fill and clipping are simply
7 # done with PStricks or Tikz but the other
8 # postprocessors don't all have this
9 # facility so the following calculates
10 # shading boundaries and lines.
11
12 define ShadePoint { testexpr(i, $1<f1, $1<f2, $1<f3 )
13 Px: $1 between P0 and Pz
14 S: move from Px to Px+Up
15 case(i+1,
16 M4L: LCintersect(S,T1,stripwd/2)
17 M4R: ($1-f2)/(1-f2) between P9 and P8
18 ,
19 M4L: $1/f1 between P0 and P4
20 M4R: $1/f1 between P0 and P3
21 ,
22 M4L: Intersect_(S,M57)
23 M4R: LCintersect(S,P1,stripwd/2)
24 ,
25 M4L: Intersect_(S,M57)
26 M4R: ($1-f2)/(1-f2) between P9 and P8
27 )
28 line outlined rgbstring($2,$3,$4) from M4L to M4R
29 }
30
31 define ShadeTail { testexpr(i, $1<g1, $1<g2, $1<g3 )
32 Px: $1 between T4 and Qz
33 S: move from Px to Px+AcrossTail
34 case(i+1,
35 M4L: LCintersect(S,T1,stripwd/2,R)
36 M4R: LCintersect(S,T1,stripwd/2)
37 ,
38 M4L: $1/g1 between T5 and T6
39 M4R: $1/g1 between T3 and T2
40 ,
41 M4L: LCintersect(S,T1,stripwd/2,R)
42 M4R: $1/g2 between T3 and P6
43 ,
44 M4L: LCintersect(S,T1,stripwd/2,R)
45 M4R: ($1-g2)/(g3-g2) between P6 and P7
46 )
47 line outlined rgbstring($2,$3,$4) from M4L to M4R
48 }
49
50 # `recycle(width)'
51 define(`recycle',`[ Origin: Here
52 space = 2*linethick pt__
53 stripwd = ($1-space)/3.765544
54 for angle=0 to 240 by 120 do {
55 Right: (dprot(angle*dtor_,stripwd,0))
56 Up: (dprot(angle*dtor_,0,stripwd/2))
57 P0: Here+Right*space/stripwd
58 Axis: move from P0 to P0+Right*3/4; P1: Here
59 P2: P1-Up
60 P3: 1.5 between P1 and P2
61 P4: P1 + (P1-P3)
62 P5: P1 + Up
63 P6: P5+Right/sqrt(3)/2
64 P7: P6+(P6-P5)
65 T1: 2 between P1 and P6
66 P8: T1+(dprot((angle-30)*dtor_,stripwd/2,0))
67 P9: P1+(P8-T1)
68 T2: T1+(dprot((angle+210)*dtor_,stripwd/2,0))
69 AcrossTail: T1-T2
70 T3: P6+(dprot((angle+120)*dtor_,stripwd,0))
71 T4: T3+AcrossTail
72 T5: 2 between T3 and T4
73 T6: 2 between T2 and T1
74 V: move from P8 to P8-Up; Pz: Intersect_(Axis,V)
75 t = distance(P0,Pz)
76 f1 = distance(P1,P0) / t
77 V: move from P9 to P9+Up; R: Intersect_(Axis,V); f2 = distance(P0,R) / t
78 V: move from P7 to P7-Up; R: Intersect_(Axis,V); f3 = distance(P0,R) / t
79 n = int(t/lthick*1.5)
80 M57: move from P5 to P7
81 ShadeObject( ShadePoint,n,
82 0,1,1,1,
83 1,0.5,0.5,0.5) with .Origin at Origin
84 point
85 J: move from T4 to T1; Qz: LCintersect(J,T1,stripwd/2,R)
86 u=distance(T4,Qz)
87 g1 = distance(T1,T4) / u
88 g2 = stripwd / u
89 V: move from P7 to P7+AcrossTail; R: Intersect_(V,J)
90 g3 = distance(R,T4) / u
91 m = int(u/lthick*1.5)
92 ShadeObject(ShadeTail,m,
93 0,1,1,1,
94 1,0.5,0.5,0.5) with .Origin at Origin
95 tail
96 # { for i=0 to 9 do { exec sprintf("{\"P%g\" at P%g}",i,i) } }
97 # { for i=1 to 6 do { exec sprintf("{\"T%g\" at T%g}",i,i) } }
98 move to T4
99 }
100 ]')
101 define(`tail',`line from P7 to P6 then to T3 then to T5 then to T6
102 arc cw to P7 with .c at T1')
103
104 define(`point',`line from P2 to P3 then to P0 then to P4 then to P5 then to P7
105 arc ccw to P8 with .c at T1
106 line to P9
107 arc cw to P2 with .c at P1')
108
109 recycle(2)
110 ]
111 [
112 # yinyang.m4
113 ifdpic(`
114 circlerad = 0.5
115 shade(0,
116 A: arc ccw rad circlerad*2 to Here+(4*circlerad,0)
117 )
118 B: circle colored "white" with .c at 1/4<A.w,A.e>
119 arc cw rad circlerad from B.e to B.w with .c at B.c
120 circle colored "black" with .c at 3/4<A.w,A.e>
121 circle rad circlerad*2 with .c at A.c
122 circle rad circlerad/3 fill_(0) at 0.5<A.w,A.c>
123 circle rad circlerad/3 fill_(1) at 0.5<A.c,A.e>
124 ',`
125 box wid 1 ht 0.75 "Yinyang.m4" "requires" "dpic"
126 ')
127 ] with .w at last [].e+(0.2,0)
128 .PE