ma-cb-graphics.tex /size: 8057 b    last modification: 2020-07-01 14:35
1\startenvironment ma-cb-graphics
2
3% These graphics were made when I had little experience in MetaPost so
4% they are not that efficient or nicely codes. Sorry about that.
5
6\definecolor[ShapeDarkLine]  [s=.4]
7\definecolor[ShapeDarkDots]  [r=1]
8\definecolor[ShapeDarkEnd]   [g=1]
9\definecolor[ShapeLightLine] [s=.95]
10\definecolor[ShapeLightDots] [r=.9,g=,5,b=.5]
11\definecolor[ShapeLightFill] [s=.95]
12\definecolor[ShapeLightFrame][r=.5,g=.50,b=.9]
13
14\startuseMPgraphic{basic-shape-dark}
15    color shapedotscolor ; shapedotscolor := \MPcolor{ShapeDarkDots} ;
16    color shapelinecolor ; shapelinecolor := \MPcolor{ShapeDarkLine} ;
17    \includeMPgraphic{basic-shape}
18\stopuseMPgraphic
19
20\startuseMPgraphic{basic-shape-light}
21    color shapedotscolor ; shapedotscolor := \MPcolor{ShapeLightDots} ;
22    color shapelinecolor ; shapelinecolor := \MPcolor{ShapeLightLine} ;
23    \includeMPgraphic{basic-shape}
24\stopuseMPgraphic
25
26\startuseMPgraphic{basic-shape}
27    w := OverlayWidth  ; width  := 100 ; wfactor := w/width ;
28    h := OverlayHeight ; height := 100 ; hfactor := h/height ;
29    d := OverlayOffset ;
30    %
31    def random_delta (expr d) =
32        d - (uniformdeviate 2d)
33    enddef;
34    %
35    z1 = (0,height) ;
36    z2 = (0,0) ;
37    z3 = (width,0) ;
38    z4 = (width,height) ;
39    %
40    z5 = (  width+random_delta(.2width),height+random_delta(.2height)) ;
41    z6 = (.5width+random_delta(.1width),height+random_delta(.1height)) ;
42    %
43    pickup pencircle
44        xscaled (OverlayLineWidth/   wfactor)
45        yscaled (OverlayLineWidth/(2*hfactor))
46        rotated 30 ;
47    %
48    draw z5 .. z1 .. z2 .. z3 .. z4 .. z6 withcolor shapelinecolor ;
49    %
50    pickup pencircle
51        xscaled (OverlayLineWidth/wfactor)
52        yscaled (OverlayLineWidth/hfactor) ;
53    %
54    draw z1 withcolor shapedotscolor ;
55    draw z2 withcolor shapedotscolor ;
56    draw z3 withcolor shapedotscolor ;
57    draw z4 withcolor shapedotscolor ;
58    draw z5 withcolor shapedotscolor ;
59    draw z6 withcolor shapedotscolor ;
60    %
61    currentpicture := currentpicture xysized (w,h) ;
62\stopuseMPgraphic
63
64\startuniqueMPpagegraphic{chapter-state}
65    color shapelinecolor ; shapelinecolor := \MPcolor{ShapeDarkLine} ;
66    %
67    delta  := OverlayOffset ;
68    width  := OverlayWidth - 2*delta ;
69    height := (OverlayHeight - 2*delta) / 3 ;
70    %
71    z1 = (0,3height) ;
72    z2 = (0,2height) ;
73    z3 = (if not odd RealPageNumber : - fi width,1.5height) ;
74    z4 = (0,height) ;
75    z5 = (0,0) ;
76    %
77    pickup pencircle
78        xscaled delta
79        yscaled .5delta
80        rotated 30 ;
81    %
82    draw z1 -- z2{up} .. z3 .. {up} z4 -- z5 withcolor shapelinecolor ;
83    %
84    pickup pencircle
85        scaled delta ;
86    %
87    draw z1 withcolor red ;
88    draw z2 withcolor red ;
89    draw z3 withcolor red ;
90    draw z4 withcolor red ;
91    draw z5 withcolor red ;
92    %
93\stopuniqueMPpagegraphic
94
95\startreusableMPgraphic{pagenumber-state}
96    color shapelinecolor ; shapelinecolor := \MPcolor{ShapeDarkLine} ;
97    %
98    delta  := OverlayOffset ;
99    width  := OverlayWidth - 2delta ;
100    height := OverlayHeight - 2delta ;
101    lines  := 5*OverlayOffset ;
102    %
103    z1 = (0,0) ;
104    z2 = (lines,0) ;
105    z3 = (.5width,height) ;
106    z4 = (width-lines,0) ;
107    z5 = (width,0) ;
108    %
109    pickup pencircle
110        xscaled delta
111        yscaled .5delta
112        rotated 30;
113    %
114    draw z1 -- z2 {dir 135} ... z3 ... {dir -135} z4 -- z5 withcolor shapelinecolor ;
115    %
116    pickup pencircle
117        scaled delta ;
118    %
119    draw z1 withcolor red ;
120    draw z2 withcolor red ;
121    draw z3 withcolor red ;
122    draw z4 withcolor red ;
123    draw z5 withcolor red ;
124    %
125\stopreusableMPgraphic
126
127\startreusableMPgraphic{manualsymbol}
128    logo_type := 401 ;
129    input "mp-prag" ;
130    currentpicture := currentpicture scaled 0.25 ;
131\stopreusableMPgraphic
132
133\startuseMPgraphic{frame-shape}
134    delta  := OverlayOffset ;
135    width  := OverlayWidth - 2delta ;
136    height := OverlayHeight - 2delta ;
137    %
138    vardef gamma =
139        g := OverlayOffset ; ((g/3) + (uniformdeviate (2g/3)))
140    enddef;
141    %
142    z1 = (0,0) ;
143    z2 = (width,0) ;
144    z3 = (width,height) ;
145    z4 = (0,height) ;
146    %
147    x12= .5[x1,x2] ; y12=y1 + gamma ;
148    y23= .5[y2,y3] ; x23=x2 - gamma ;
149    x34= .5[x3,x4] ; y34=y3 - gamma ;
150    y41= .5[y4,y1] ; x41=x4 + gamma ;
151    %
152    pickup pencircle
153        xscaled OverlayLineWidth
154        yscaled .5OverlayLineWidth
155        rotated 30;
156    %
157    path p;
158    p :=
159        z1..z12..z2 &
160        z2..z23..z3 &
161        z3..z34..z4 &
162        z4..z41..z1 &
163        cycle ;
164    %
165    fill p withcolor shapefillcolor ;
166    draw p withcolor shapelinecolor ;
167\stopuseMPgraphic
168
169\startuseMPgraphic{setup-shape}
170    color shapelinecolor ; shapelinecolor := \MPcolor{ShapeLightFrame} ;
171    color shapefillcolor ; shapefillcolor := \MPcolor{ShapeLightFill} ;
172    \includeMPgraphic{frame-shape}
173\stopuseMPgraphic
174
175% \startuseMPgraphic{setup-shape-x}
176%     color shapelinecolor ; shapelinecolor := \MPcolor{ShapeLightFrame} ;
177%     color shapelinecolor ; shapelinecolor := \MPcolor{ShapeLightFill} ;
178%     \includeMPgraphic{frame-shape}
179% \stopuseMPgraphic
180
181\startuniqueMPgraphic{note-rule}
182    color shapelinecolor ; shapelinecolor := \MPcolor{ShapeDarkLine} ;
183    color shapeendcolor  ; shapeendcolor  := \MPcolor{ShapeDarkEnd} ;
184    %
185    draw bottomboundary OverlayBox withcolor shapelinecolor withpen pencircle scaled  OverlayLineWidth ;
186    draw llcorner       OverlayBox withcolor shapeendcolor  withpen pencircle scaled 3OverlayLineWidth ;
187    draw lrcorner       OverlayBox withcolor shapeendcolor  withpen pencircle scaled 3OverlayLineWidth ;
188    %
189\stopuniqueMPgraphic
190
191\startuniqueMPgraphic{column-rule}
192    color shapelinecolor ; shapelinecolor := \MPcolor{ShapeDarkLine} ;
193    color shapeendcolor  ; shapeendcolor  := \MPcolor{ShapeDarkEnd} ;
194    %
195    draw leftboundary OverlayBox withcolor shapelinecolor withpen pencircle scaled  OverlayLineWidth ;
196    draw ulcorner     OverlayBox withcolor shapeendcolor  withpen pencircle scaled 3OverlayLineWidth ;
197    draw llcorner     OverlayBox withcolor shapeendcolor  withpen pencircle scaled 3OverlayLineWidth ;
198    %
199\stopuniqueMPgraphic
200
201% alternative implemenation
202%
203% \startuniqueMPgraphic{column-rule}{height,linewidth}
204%     color   shapelinecolor ; shapelinecolor := \MPcolor{ShapeDarkLine} ;
205%     color   shapeendcolor  ; shapeendcolor  := \MPcolor{ShapeDarkEnd} ;
206%     numeric shapelinewidth ; shapelinewidth := \MPvar{linewidth} ;
207%     pair    shapeboundary  ; shapeboundary  := (0,\MPvar{height}) ;
208%     %
209%     draw origin -- shapeboundary withcolor shapelinecolor withpen pencircle scaled  shapelinewidth ;
210%     draw origin                  withcolor shapeendcolor  withpen pencircle scaled 3shapelinewidth ;
211%     draw           shapeboundary withcolor shapeendcolor  withpen pencircle scaled 3shapelinewidth ;
212%     %
213% \stopuniqueMPgraphic
214
215% todo
216
217% \startreusableMPgraphic{clip:six}
218%     %
219%     delta  := OverlayOffset ;
220%     height := OverlayWidth - delta ;
221%     %
222%     color green; green := (.1,.8,.1) ;
223%     %
224%     z1 = (0,0) ;
225%     z2 = (0,height) ;
226%     %
227%     pickup pencircle
228%         scaled OverlayLineWidth ;
229%     %
230%     draw z1 -- z2 withcolor .5white ;
231%     %
232%     pickup pencircle
233%         scaled 3OverlayLineWidth ;
234%     %
235%     draw z1 withcolor green ;
236%     draw z2 withcolor green ;
237%     %
238% \stopreusableMPgraphic
239
240% \startreusableMPgraphic{clip:seven}
241%     %
242%     width  := OverlayWidth ;
243%     height := OverlayHeight  ;
244%     delta  := OverlayOffset ;
245%     %
246%     color green ; green := (.1,.8,.1) ;
247%     %
248%     x1 = x4 = 0 ; x2 = x3 = width ;
249%     y1 = y2 = 0 ; y3 = y4 = height ;
250%     %
251%     pickup pencircle
252%         scaled OverlayLineWidth ;
253%     %
254%     draw z1 -- z2 -- z3 -- z4 -- cycle withcolor .white ;
255%     %
256%     pickup pencircle
257%         scaled 3OverlayLineWidth ;
258%     %
259%     draw z1 withcolor green ;
260%     draw z2 withcolor green ;
261%     draw z3 withcolor green ;
262%     draw z4 withcolor green ;
263%     %
264% \stopreusableMPgraphic
265
266\stopenvironment
267