metafun-reference.tex /size: 26 Kb    last modification: 2023-12-21 09:43
1% language=us runpath=texruns:manuals/metafun
2
3\startcomponent metafun-reference
4
5\environment metafun-environment
6
7\startchapter[reference=reference,title={Reference}]
8
9\startintro
10
11In this chapter, we will demonstrate most of the drawing related primitives and
12macros as present in plain \METAPOST\ and \METAFUN\ extensions.
13
14If a path is shown and|/|or a transformation is applied, we show the original in
15red and the transformed path or point in yellow. The small dark gray crosshair is
16the origin and the black rectangle the bounding box. In some drawings, in light
17gray we show the points that make up the path.
18
19This list describes traditional \METAPOST\ and the stable part of \METAFUN. As
20\METAPOST\ evolves, new primitives are added but they are not always that
21relevant to us. If you browse the \METAFUN\ sources you will for sure notice more
22functionality than summarized here. Most of that is meant for usage in \CONTEXT\
23and not exposed to the user. Other macros are still somewhat experimental but
24might become more official at some point. The same is true for \METAFUN\
25commands: not all make sense for daily usage and some are just there as helper
26for additional modules.
27
28\stopintro
29
30\startsection[title={Paths}]
31
32\index{paths}
33
34\ShowSampleA {mc} {pair}                  {(1,.5)}
35\ShowSampleA {mm} {pair .. pair}          {(0,0)..(.75,0)..(1,.25)..(1,1)}
36\ShowSampleA {mm} {pair ... pair}         {(0,0)..(.75,0)...(1,.25)..(1,1)}
37\ShowSampleA {mm} {pair -- pair\quad (a)} {(0,0)--(.75,0)--(1,.25)--(1,1)}
38\ShowSampleA {mm} {pair -- pair\quad (b)} {(0,0)..(.75,0)--(1,.25)..(1,1)}
39\ShowSampleA {mm} {pair --- pair}         {(0,0)..(.75,0)---(1,.25)..(1,1)}
40
41\ShowSampleA {mm} {pair softjoin pair}      {(0,0)..(.75,0) softjoin (1,.25)..(1,1)}
42\ShowSampleA {mp} {controls pair}           {(0,0)..controls (.75,0)..(1,1)}
43\ShowSampleA {mp} {controls pair and pair}  {(0,0)..controls (.75,0) and (1,.25)..(1,1)}
44\ShowSampleA {mp} {tension numeric}         {(0,0)..(.75,0)..tension 2.5..(1,.25)..(1,1)}
45\ShowSampleA {mp} {tension num.. and num..} {(0,0)..(.75,0)..tension 2.5 and 1.5..(1,.25)..(1,1)}
46\ShowSampleA {mp} {tension atleast numeric} {(0,0)..(.75,0)..tension atleast 1..(1,.25)..(1,1)}
47
48\ShowSampleA {mp} {cycle}        {(0,0)--(1,0)--(1,1)--cycle}
49\ShowSampleA {mp} {curl numeric} {(0,0){curl 1}..(.75,0)..(1,.25)..(1,1)}
50\ShowSampleA {mp} {dir numeric}  {(0,0){dir 30}..(1,1)}
51\ShowSampleA {mm} {left}         {(0,0){left}..(1,1)}
52\ShowSampleA {mm} {right}        {(0,0){right}..(1,1)}
53\ShowSampleA {mm} {up}           {(0,0){up}..(1,1)}
54\ShowSampleA {mm} {down}         {(0,0){down}..(1,1)}
55
56\ShowSampleA {mp} {path \& path} {(0,0)..(.75,.25) \& (.75,.25)..(1,1)}
57
58\ShowSampleA {mv} {unitvector}  {origin--unitvector(1,1)}
59\ShowSampleA {mp} {dir}         {origin--dir(45)}
60\ShowSampleA {mp} {angle}       {origin--dir(angle(1,1))}
61
62\ShowSampleA {mv} {fullcircle}  {fullcircle}
63\ShowSampleA {fv} {unitcircle}  {unitcircle}
64\ShowSampleA {fv} {fullsquare}  {fullsquare}
65\ShowSampleA {mv} {unitsquare}  {unitsquare}
66\ShowSampleA {fv} {fulltriangle}{fulltriangle}
67\ShowSampleA {fv} {unittriangle}{unittriangle}
68\ShowSampleA {fv} {fulldiamond} {fulldiamond}
69\ShowSampleA {fv} {unitdiamond} {unitdiamond}
70
71\ShowSampleA {mv} {halfcircle}    {halfcircle}
72\ShowSampleA {mv} {quartercircle} {quartercircle}
73
74\ShowSampleA {fv} {llcircle} {llcircle}
75\ShowSampleA {fv} {lrcircle} {lrcircle}
76\ShowSampleA {fv} {urcircle} {urcircle}
77\ShowSampleA {fv} {ulcircle} {ulcircle}
78\ShowSampleA {fv} {tcircle}  {tcircle}
79\ShowSampleA {fv} {bcircle}  {bcircle}
80\ShowSampleA {fv} {lcircle}  {lcircle}
81\ShowSampleA {fv} {rcircle}  {rcircle}
82
83\ShowSampleA {fv} {triangle}      {triangle}
84\ShowSampleA {fv} {righttriangle} {righttriangle}
85\ShowSampleA {fv} {uptriangle}    {uptriangle}
86\ShowSampleA {fv} {lefttriangle}  {lefttriangle}
87\ShowSampleA {fv} {downtriangle}  {downtriangle}
88
89\ShowSampleA {fv} {lltriangle} {lltriangle}
90\ShowSampleA {fv} {lrtriangle} {lrtriangle}
91\ShowSampleA {fv} {urtriangle} {urtriangle}
92\ShowSampleA {fv} {ultriangle} {ultriangle}
93
94\ShowSampleA {mm} {flex(pair,pair,pair)}
95                  {flex ((0,0),(1,1),(1,0))}
96\ShowSampleA {mm} {superellipse(pair,p..,p..,p..,num..)}
97                  {superellipse((1,.5),(.5,1),(0,.5),(.5,0),.75)}
98
99\ShowSampleA {fm} {path smoothed numeric/pair}           {unitsquare scaled 1.5 smoothed .2}
100\ShowSampleA {fm} {path cornered numeric/pair}           {lltriangle scaled 1.5 cornered .2}
101\ShowSampleA {fm} {path superellipsed numeric}           {unitsquare scaled 1.5 superellipsed .75}
102\ShowSampleA {fm} {path randomized numeric/pair}         {unitsquare scaled 1.5 randomized (.2,.2)}
103\ShowSampleA {fm} {path randomizedcontrols numeric/pair} {fullcircle scaled 1.5 randomizedcontrols (.2,.2)}
104\ShowSampleA {fm} {path squeezed numeric/pair}           {unitsquare scaled 1.5 squeezed (.2,.1)}
105\ShowSampleA {fm} {path snapped numeric/pair}            {fullcircle scaled 1.5 snapped (.2,.1)}
106
107\ShowSampleB {fm} {punked path}
108         {unitcircle scaled 1.5}
109  {punked unitcircle scaled 1.5}
110
111\ShowSampleB {fm} {curved path}
112         {((0,0)--(.2,1)--(1,.2)--cycle)}
113  {curved ((0,0)--(.2,1)--(1,.2)--cycle)}
114
115\ShowSampleB {fm} {laddered path}
116           {((0,0)--(1.4,.8)--(2.8,1.2)--(6.2,1.6))}
117  {laddered ((0,0)--(1.4,.8)--(2.8,1.2)--(6.2,1.6))}
118
119\ShowSampleB {fm} {path paralleled distance}
120           {((0,0)--(5,1))}
121           {((0,0)--(5,1)) paralleled .25}
122
123\ShowSampleB {fm} {shortened path}
124    {((0,0)--(6,1))}
125    {((0,0)--(6,1)) shortened 1}
126
127\ShowSampleB {fm} {unspiked path}
128           {((0,0)--(1,0)--(1,1)--(2,1)--(1,1)--(0,1)) shifted (-3,0)}
129  {unspiked ((0,0)--(1,0)--(1,1)--(2,1)--(1,1)--(0,1))}
130
131\ShowSampleB {fm} {simplified path}
132             {((0,0)--(1,0)--(2,0)--(2,1)--(0,1)--cycle) shifted (-3,0)}
133  {simplified ((0,0)--(1,0)--(2,0)--(2,1)--(0,1)--cycle)}
134
135\ShowSampleB {fm} {path blownup numeric/pair}
136             {fullcircle scaled 1.5}
137            {(fullcircle scaled 1.5) blownup .1}
138
139\ShowSampleB {fm} {path stretched numeric/pair\quad (a)}
140             {fullcircle scaled 1.5}
141            {(fullcircle scaled 1.5) stretched (1.1,0.8)}
142
143\ShowSampleB {fm} {path stretched numeric\quad (b)}
144             {((0,0)--(1,1))}
145             {((0,0)--(1,1)) stretched 1.5}
146
147\ShowSampleB {fm} {path xstretched numeric}
148             {fullcircle}
149             {fullcircle xstretched 5}
150
151\ShowSampleB {fm} {path ystretched numeric}
152             {fullcircle}
153             {fullcircle ystretched 1.5}
154
155\ShowSampleB {fm} {path enlonged numeric}
156             {((0,0)--(1,1))}
157             {((0,0)--(1,1)) enlonged 1.5}
158
159\ShowSampleB {fm} {path shorted numeric}
160             {((0,0)--(2,2))}
161             {((0,0)--(2,2)) shortened 0.5}
162
163\ShowSampleA {fm} {roundedsquare(num..,num..,num..)}
164                  {roundedsquare(2,1,.2)}
165
166\ShowSampleA {fm} {tensecircle(num..,num..,num..)}
167                  {tensecircle(2,1,.2)}
168
169\ShowSampleA {fm} {pair crossed size}
170                  {origin crossed 1}
171
172\ShowSampleA {fm} {path crossed size}
173                  {fullcircle scaled 2 crossed .5}
174
175\ShowSampleA {fm} {(constructed)function}
176                  {constructedfunction("--")("x","sin(x)",0,2pi,pi/10)}
177
178\ShowSampleA {fm} {curvedfunction}
179                  {curvedfunction("x","sin(x)",0,2pi,pi/10)}
180
181\ShowSampleA {fm} {straightfunction}
182                  {straightfunction("x","sin(x)",0,2pi,pi/10)}
183
184\ShowSampleA {fm} {constructedpath}
185                  {constructedpath("..")((0,0),(1,2),(2,1),(3,2))}
186
187\ShowSampleA {fm} {curvedpath}
188                  {curvedpath((0,0),(1,2),(2,1),(3,2))}
189
190\ShowSampleA {fm} {straightpath}
191                  {straightpath((0,0),(1,2),(2,1),(3,2))}
192
193\ShowSampleA {fm} {leftarrow}
194                  {leftarrow(fullcircle,3,2)}
195
196\ShowSampleA {fm} {rightarrow}
197                  {rightarrow(fullcircle,3,2)}
198
199\ShowSampleA {fm} {centerarrow}
200                  {centerarrow(fullcircle,3,2)}
201
202\ShowSampleX {fm} {arrowhead} {draw arrowhead fullcircle}
203\ShowSampleX {fm} {arrowpath} {draw arrowpath fullcircle}
204
205\ShowSampleA {mm} {buildcycle}
206                  {buildcycle(fullcircle,fullsquare)}
207
208\ShowSampleA {fm} {circularpath} {circularpath(4)}
209\ShowSampleA {fm} {squarepath}   {squarepath(4)}
210\ShowSampleA {fm} {linearpath}   {linearpath(4)}
211
212\stopsection
213
214\startsection[title={Transformations}]
215
216\index{transformations}
217
218\ShowSampleB {mp} {path scaled numeric}        {fullcircle} {fullcircle scaled .50}
219\ShowSampleB {mp} {path xscaled numeric}       {fullcircle} {fullcircle xscaled .25}
220\ShowSampleB {mp} {path yscaled numeric}       {fullcircle} {fullcircle yscaled .25}
221\ShowSampleB {mp} {path zscaled pair}          {fullcircle} {fullcircle zscaled (2,.25)}
222\ShowSampleB {mp} {path xyscaled numeric/pair} {fullcircle} {fullcircle xyscaled (.5,.7)}
223\ShowSampleB {mp} {path xyscaled pair}         {fullcircle} {fullcircle xyscaled (2,.25)}
224\ShowSampleB {mp} {path shifted pair}          {fullcircle} {fullcircle shifted (2,.25)}
225
226\ShowSampleB {fm} {path leftenlarged   numeric} {fullsquare} {fullsquare leftenlarged .25}
227\ShowSampleB {fm} {path topenlarged    numeric} {fullsquare} {fullsquare topenlarged .25}
228\ShowSampleB {fm} {path rightenlarged  numeric} {fullsquare} {fullsquare rightenlarged .25}
229\ShowSampleB {fm} {path bottomenlarged numeric} {fullsquare} {fullsquare bottomenlarged .25}
230
231\ShowSampleB {fm} {path enlarged numeric}   {fullcircle} {fullcircle enlarged .25}
232\ShowSampleB {fm} {path enlarged pair}      {fullcircle} {fullcircle enlarged (1,.25)}
233\ShowSampleB {fm} {path llenlarged numeric} {fullcircle} {fullcircle llenlarged .25}
234\ShowSampleB {fm} {path lrenlarged numeric} {fullcircle} {fullcircle lrenlarged .25}
235\ShowSampleB {fm} {path urenlarged numeric} {fullcircle} {fullcircle urenlarged .25}
236\ShowSampleB {fm} {path ulenlarged numeric} {fullcircle} {fullcircle ulenlarged .25}
237\ShowSampleB {fm} {path llenlarged pair}    {fullcircle} {fullcircle llenlarged (1,.25)}
238\ShowSampleB {fm} {path lrenlarged pair}    {fullcircle} {fullcircle lrenlarged (1,.25)}
239\ShowSampleB {fm} {path urenlarged pair}    {fullcircle} {fullcircle urenlarged (1,.25)}
240\ShowSampleB {fm} {path ulenlarged pair}    {fullcircle} {fullcircle ulenlarged (1,.25)}
241\ShowSampleB {fm} {path llmoved numeric}    {fullcircle} {fullcircle llmoved .25}
242\ShowSampleB {fm} {path lrmoved numeric}    {fullcircle} {fullcircle lrmoved .25}
243\ShowSampleB {fm} {path urmoved numeric}    {fullcircle} {fullcircle urmoved .25}
244\ShowSampleB {fm} {path ulmoved numeric}    {fullcircle} {fullcircle ulmoved .25}
245\ShowSampleB {fm} {path llmoved pair}       {fullcircle} {fullcircle llmoved (1,.25)}
246\ShowSampleB {fm} {path lrmoved pair}       {fullcircle} {fullcircle lrmoved (1,.25)}
247\ShowSampleB {fm} {path urmoved pair}       {fullcircle} {fullcircle urmoved (1,.25)}
248\ShowSampleB {fm} {path ulmoved pair}       {fullcircle} {fullcircle ulmoved (1,.25)}
249\ShowSampleB {mp} {path slanted numeric}    {fullcircle} {fullcircle slanted .5}
250\ShowSampleB {mp} {path rotated numeric}    {fullsquare} {fullsquare rotated 45}
251
252\ShowSampleB {mm} {path rotatedaround(pair,numeric)}  {fullsquare} {fullsquare rotatedaround((.25,.5),45)}
253\ShowSampleB {mm} {path reflectedabout(pair,pair)}    {fullcircle} {fullcircle reflectedabout((.25,-1),(.25,+1))}
254\ShowSampleB {mp} {reverse path}                      {fullcircle} {reverse fullcircle shifted(.5,0)}
255\ShowSampleB {mm} {counterclockwise path}             {fullcircle} {counterclockwise fullcircle shifted(.5,0)}
256\ShowSampleB {mm} {tensepath path}                    {fullcircle} {tensepath fullcircle}
257
258\ShowSampleB {mp} {subpath (numeric,numeric) of path} {fullcircle} {subpath (1,5) of fullcircle}
259\ShowSampleB {mm} {path cutbefore pair} {fullcircle} {fullcircle cutbefore point 3 of fullcircle}
260\ShowSampleB {mm} {path cutafter  pair} {fullcircle} {fullcircle cutafter point 3 of fullcircle}
261\ShowSampleB {mm} {path cutends .1} {fullcircle} {fullcircle cutends .5}
262
263\ShowSampleC {mp} {llcorner path} {fullcircle} {llcorner fullcircle}
264\ShowSampleC {mp} {lrcorner path} {fullcircle} {lrcorner fullcircle}
265\ShowSampleC {mp} {urcorner path} {fullcircle} {urcorner fullcircle}
266\ShowSampleC {mp} {ulcorner path} {fullcircle} {ulcorner fullcircle}
267\ShowSampleC {mm} {center   path} {fullcircle} {center   fullcircle}
268
269\ShowSampleD {fm} {boundingbox      path} {fullcircle} {boundingbox fullcircle}
270\ShowSampleD {fm} {boundingcircle   path} {fullsquare} {boundingcircle fullsquare}
271\ShowSampleD {fm} {innerboundingbox path} {fullcircle} {innerboundingbox fullcircle}
272\ShowSampleD {fm} {outerboundingbox path} {fullcircle} {outerboundingbox fullcircle}
273
274\ShowSampleDD {fm} {bottomboundary path} {fullcircle} {bottomboundary fullcircle}
275\ShowSampleDD {fm} {leftboundary   path} {fullcircle} {leftboundary fullcircle}
276\ShowSampleDD {fm} {topboundary    path} {fullcircle} {topboundary fullcircle}
277\ShowSampleDD {fm} {rightboundary  path} {fullcircle} {rightboundary fullcircle}
278
279\ShowSampleP {fm} {bbwidth path} {draw textext(decimal bbwidth (fullcircle xscaled 100 yscaled 200))}
280\ShowSampleP {fm} {bbwidth path} {draw textext(decimal bbheight (fullcircle xscaled 100 yscaled 200))}
281
282\ShowSampleE {fm} {path/picture xsized numeric}  {xsized 3cm} {currentpicture xsized 5cm}
283\ShowSampleE {fm} {path/picture ysized numeric}  {ysized 2cm} {currentpicture ysized 2cm}
284\ShowSampleE {fm} {path/picture xysized numeric} {xysized (3cm,2cm)} {currentpicture xysized (3cm,2cm)}
285
286\ShowSampleP {fm}
287  {area path}
288  {draw area ((0,10)--(20,20)--(30,5)--(40,10)--(50,5)--(60,5))}
289
290\ShowSampleT {mp}
291  {setbounds picture}
292  {draw fullcircle ; setbounds currentpicture to unitsquare}
293  {draw fullcircle scaled .5 InGray; setbounds currentpicture to unitsquare scaled .5}
294
295\ShowSampleT {mm}
296  {clip path}
297  {fill fullcircle ; clip currentpicture to fullsquare scaled 0.9}
298  {fill fullcircle scaled 1 InRed ; clip currentpicture to fullsquare scaled 0.9}
299
300\ShowSampleT {mm}
301  {path peepholed  path}
302  {fill (fullcircle peepholed fullsquare)}
303  {fill (fullcircle peepholed fullsquare) InRed}
304
305\ShowSampleT {fm}
306  {anchored}
307  {draw anchored.urt(textext("ll"),origin)}
308  {draw anchored.urt(textext("ll") xsized (5mm/Scale),origin) InRed ;}
309
310% \ShowSampleT {fm}
311%   {autoalign}
312%   {draw textext.autoalign(260)("260")}
313%   {draw textext.autoalign(260)("260")}
314
315% draw textext.autoalign(260)("\strut oeps 3") ;
316
317\ShowSampleX {fm}
318    {path crossingunder path}
319    {draw (fullsquare rotated 45) crossingunder fullsquare}
320
321\stopsection
322
323\startsection[title={Points}]
324
325\index{points}
326
327%ShowSampleF {mp} {center path}                 {fullcircle} {center fullcircle}
328\ShowSampleF {mm} {top pair}                    {fullcircle} {top center fullcircle}
329\ShowSampleF {mm} {bot pair}                    {fullcircle} {bot center fullcircle}
330\ShowSampleF {mm} {lft pair}                    {fullcircle} {lft center fullcircle}
331\ShowSampleF {mm} {rt pair}                     {fullcircle} {rt  center fullcircle}
332\ShowSampleF {mp} {point       numeric of path} {fullcircle} {point 2 of fullcircle}
333\ShowSampleF {fm} {point       numeric on path} {fullcircle} {point .5 on fullcircle}
334\ShowSampleF {fm} {point    numeric along path} {fullcircle} {point 1cm along fullcircle}
335\ShowSampleF {mp} {precontrol  numeric of path} {fullcircle} {precontrol 2 of fullcircle}
336\ShowSampleF {mp} {postcontrol numeric of path} {fullcircle} {postcontrol 2 of fullcircle}
337\ShowSampleF {mp} {directionpoint pair of path} {fullcircle} {directionpoint (2,3) of fullcircle}
338
339\ShowSampleG {mc} {numeric[pair,pair]} {(1,1)} {.5[(0,0),(1,1)]}
340
341\ShowSampleH {mm} {path intersectionpoint path} {fullcircle} {fulldiamond}
342                  {fullcircle intersectionpoint fulldiamond}
343
344\ShowSampleHH {mm} {interpath(numeric,path,path}
345                   {interpath(.8,fullcircle,fullsquare)}
346
347\ShowSampleHH {fm} {interpolated(numeric,path,path}
348                   {interpolated(.8,fullcircle,fullsquare)}
349
350\ShowSampleO {mm} {right} {draw left}
351\ShowSampleO {mm} {up}    {draw up}
352\ShowSampleO {mm} {left}  {draw left}
353\ShowSampleO {mm} {down}  {draw down}
354
355\stopsection
356
357\startsection[title={Colors}]
358
359\index{colors}
360
361\ShowSampleI {mp} {withcolor rgbcolor} {withcolor (.625,0,0)}
362\ShowSampleI {mp} {withrgbcolor rgbcolor} {withrgbcolor (.625,0,0)}
363\ShowSampleI {mp} {withcmykcolor cmykcolor} {withcmykcolor (.375,0,0,0)}
364\ShowSampleI {mp} {withgray / withgrey numeric} {withgray .625}
365\ShowSampleI {mp} {withcolor namedcolor} {withcolor namedcolor("darkblue")}
366\ShowSampleI {mp} {withcolor spotcolor} {withcolor spotcolor("tempone",red/2)}
367\ShowSampleI {mp} {withcolor multitonecolor} {withcolor .2 * multitonecolor("temptwo",blue/2,yellow/3)}
368
369Remark: at the time of this writing only Acrobat shows spot- and multitonecolors
370properly. Possible indications of a viewing problem are factors not being applied
371(in the page stream) or colors that are way off.
372
373\ShowSampleU {mp} {red}     {fill fullcircle scaled 2 withcolor red/2}
374\ShowSampleU {mp} {green}   {fill fullcircle scaled 2 withcolor green/2}
375\ShowSampleU {mp} {blue}    {fill fullcircle scaled 2 withcolor blue/2}
376\ShowSampleU {mp} {cyan}    {fill fullcircle scaled 2 withcolor cyan/2}
377\ShowSampleU {mp} {magenta} {fill fullcircle scaled 2 withcolor magenta/2}
378\ShowSampleU {mp} {yellow}  {fill fullcircle scaled 2 withcolor yellow/2}
379\ShowSampleU {mp} {black}   {fill fullcircle scaled 2 withcolor black/2}
380\ShowSampleU {mp} {white}   {fill fullcircle scaled 2 withcolor white/2}
381
382\ShowSampleU {mp} {blackcolor} {fill fullcircle withcolor blackcolor red}
383
384%ShowSampleI {fm} {withcolor cmyk(c,m,y,k)}  {withcolor cmyk(0,.625,.625,0)}
385%ShowSampleI {fm} {withcolor transparent(n.m,color)}  {withcolor transparent(1,.625,red)}
386
387\ShowSampleI {fm} {withtransparency(num,num)} {withcolor red withtransparency (1,.625)}
388
389% \ShowSampleZ {fm} {withshade numeric} {Shades need to be declared before they can be (re)used.}
390
391\startMPinclusions
392    defineshade cshade withshademethod "circular" ;
393    defineshade lshade withshademethod "linear" ;
394\stopMPinclusions
395
396\ShowSampleW {fm} {shaded someshade }
397    {fill fullsquare shaded lshade}
398    {fill fullsquare scaled 2cm shaded lshade}
399
400This assumes the definition:
401
402\starttyping
403defineshade lshade withshademethod "linear" ;
404\stoptyping
405
406\ShowSampleW {fm} {shaded someshade}
407    {fill fullcircle shaded cshade}
408    {fill fullcircle scaled 2cm shaded cshade}
409
410This assumes the definition:
411
412\starttyping
413defineshade cshade withshademethod "circular" ;
414\stoptyping
415
416%     withshadefactor 1
417%     withshadedomain (0,1)
418%     withshadecolors (black,white)
419%     withtransparency (1,.5)
420
421% \startMPcode
422%     fill fullcircle scaled 3cm
423%         shaded myshade
424%         withshadefactor 0.7
425%     ;
426% \stopMPcode
427
428% \startMPcode
429%     fill fullcircle scaled 3cm
430%         shaded myshade
431%         withshadecolors (red,green)
432%         withshadefactor 1
433%         withtransparency (1,.75)
434%     ;
435% \stopMPcode
436
437% \startMPcode
438%     fill fullcircle scaled 3cm
439%         shaded myshade ;
440%         withshadefactor 1
441%         withshadedomain (0,1)
442%         withshadecolors (green,blue)
443%         withtransparency (1,.5)
444%     ;
445% \stopMPcode
446
447% \startMPcode
448%     fill fullcircle scaled 3cm
449%         shaded myshade ;
450%         withshadefactor 1
451%         withshadedomain (0,1)
452%         withcolor blue shadedinto yellow
453%         withtransparency (1,.5)
454%     ;
455% \stopMPcode
456
457\ShowSampleV {mp}
458    {basiccolors}
459    {for i=0 upto 21 : fill ... withcolor basiccolors[i] ; endfor}
460    {for i=0 upto 21 : fill fullcircle shifted (i,0) withcolor basiccolors[i] ; endfor}
461
462\stopsection
463
464\startsection[title={Attributes}]
465
466\index{attributes}
467
468\ShowSampleII {mp} {dashed withdots} {dashed withdots}
469\ShowSampleII {mp} {dashed evenly}   {dashed evenly}
470\ShowSampleII {mp} {dashed oddly}    {dashed oddly}
471\ShowSampleII {mp} {dashpattern}     {dashed dashpattern (on .1 off .2 on .3 off .4)}
472\ShowSampleII {mp} {undashed}        {dashed evenly undashed}
473\ShowSampleII {fm} {withdashes pair} {withdashes (.1,.2)}
474
475\ShowSampleJ {mm} {pencircle transform} {pencircle}
476\ShowSampleJ {mm} {pensquare transform} {pensquare}
477\ShowSampleJ {mm} {penrazor transform}  {penrazor}
478\ShowSampleK {mm} {penspec transform}   {penspec}
479
480\ShowSampleL {mm} {draw}         {fullcircle}
481\ShowSampleL {mm} {fill}         {fullcircle}
482\ShowSampleL {mm} {filldraw}     {fullcircle}
483\ShowSampleL {mm} {drawfill}     {fullcircle}
484\ShowSampleL {mm} {drawdot}      {origin}
485\ShowSampleL {mm} {drawarrow}    {fullcircle}
486\ShowSampleL {mm} {drawdblarrow} {fullcircle}
487
488\ShowSampleL {fm} {eofill}       {fullcircle}
489
490\ShowSampleM {mm} {undraw}     {fullcircle}
491\ShowSampleM {mm} {unfill}     {fullcircle}
492\ShowSampleM {mm} {unfilldraw} {fullcircle}
493\ShowSampleM {mm} {undrawfill} {fullcircle}
494\ShowSampleM {mm} {undrawdot}  {origin}
495
496\ShowSampleQ {mm} {cutdraw} {origin--(1,1)}
497
498\ShowSampleN {mv} {butt}    {linecap := butt}    {(0,.5)--(.5,0)--(1,1)}
499\ShowSampleN {mv} {rounded} {linecap := rounded} {(0,.5)--(.5,0)--(1,1)}
500\ShowSampleN {mv} {squared} {linecap := squared} {(0,.5)--(.5,0)--(1,1)}
501
502\ShowSampleN {mv} {mitered} {linejoin := mitered} {(0,.5)--(.5,0)--(1,1)}
503\ShowSampleN {mv} {rounded} {linejoin := rounded} {(0,.5)--(.5,0)--(1,1)}
504\ShowSampleN {mv} {beveled} {linejoin := beveled} {(0,.5)--(.5,0)--(1,1)}
505
506\ShowSampleR {fm} {inverted picture}         {inverted currentpicture}
507\ShowSampleR {fm} {picture uncolored color}  {currentpicture uncolored green}
508\ShowSampleR {fm} {picture softened numeric} {currentpicture softened .8}
509\ShowSampleR {fm} {picture softened color}   {currentpicture softened (.7,.8,.9)}
510\ShowSampleR {fm} {grayed picture}           {grayed currentpicture}
511
512\stopsection
513
514\startsection[title={Text}]
515
516\index{text}
517
518\ShowSampleO {mm} {label}           {label("MetaFun",origin)}
519\ShowSampleO {mm} {label.top}   {label.top("MetaFun",origin)}
520\ShowSampleO {mm} {label.bot}   {label.bot("MetaFun",origin)}
521\ShowSampleO {mm} {label.lft}   {label.lft("MetaFun",origin)}
522\ShowSampleO {mm} {label.rt}     {label.rt("MetaFun",origin)}
523\ShowSampleO {mm} {label.llft} {label.llft("MetaFun",origin)}
524\ShowSampleO {mm} {label.lrt}   {label.lrt("MetaFun",origin)}
525\ShowSampleO {mm} {label.urt}   {label.urt("MetaFun",origin)}
526\ShowSampleO {mm} {label.ulft} {label.ulft("MetaFun",origin)}
527
528\ShowSampleW {mp} {dotlabel}
529  {dotlabel.bot("\tttf metafun",(2cm,1cm))}
530  {dotlabel.bot("\tttf metafun",(2cm,1cm))}
531
532\ShowSampleW {mp} {dotlabels + range .. thru ..}
533  {z1 = ... ; dotlabels.bot(range 1 thru 3)}
534  {z1=(0,0); z2=(10mm,10mm); z3=(20mm,15mm); ; z4=(30mm,5mm); dotlabels.bot(range 1 thru 4)}
535
536\ShowSampleW {mp} {labels + range .. thru ..}
537  {z1 = ... ; labels.bot(range 1 thru 3)}
538  {z1=(0,0); z2=(10mm,10mm); z3=(20mm,15mm); ; z4=(30mm,5mm); labels.bot(range 1 thru 4)}
539
540\ShowSampleQQ {fm}
541  {thelabel(string,pair)}
542  {draw thelabel("MetaFun",(2cm,0))}
543
544\ShowSampleQQ {fm}
545  {formatted(string)}
546  {draw textext(formatted("@0.5f",1.234))}
547
548\ShowSampleQQ {fm}
549  {format(string) : graph package}
550  {draw textext(format("@5E-2",1.234))}
551
552\ShowSampleP {mp}
553  {btex text etex}
554  {draw btex MetaTeX etex}
555
556\ShowSampleQQ {fm}
557  {textext(string)}
558  {draw textext("MetaFun")}
559
560\ShowSampleQQ {fm}
561  {thetextext(string,pair)}
562  {draw thetextext("MetaFun",(2cm,0))}
563
564% \ShowSampleQQ {fm}
565%   {graphictext string ...}
566%   {graphictext "MetaFun"}
567
568\ShowSampleQQQ {fm}
569  {outlinetext.d("string")(d)}
570  {draw outlinetext.d("MetaFun")(InRed)}
571
572\ShowSampleQQQ {fm}
573  {outlinetext.f("string")(f)}
574  {draw outlinetext.f("MetaFun")(InYellow)}
575
576\ShowSampleQQQ {fm}
577  {outlinetext.b("string")(f)(d)}
578  {draw outlinetext.b("MetaFun")(InYellow)(InRed)}
579
580\ShowSampleQQQ {fm}
581  {outlinetext.r("string")(d)(f)}
582  {draw outlinetext.r("MetaFun")(InRed)(InYellow)}
583
584\ShowSampleUU {fm}
585  {outlinetext.p("string")}
586  {draw outlinetext.p("MetaFun")}
587
588\stopsection
589
590\startsection[title={Control}]
591
592\index{loops}
593
594\ShowSampleU {mp} {for (positive step) until} {for i=0 step 2 until 8: drawdot (i,0) ; endfor}
595\ShowSampleU {mp} {for (negative step) until} {for i=6 step -2 until 0: drawdot (i,0) ; endfor}
596\ShowSampleU {mm} {for upto} {for i=0 upto 12: drawdot (i,0) ; endfor}
597\ShowSampleU {mm} {for downto} {for i=10 downto 0: drawdot (i,0) ; endfor}
598\ShowSampleU {mm} {forsuffixes} {forsuffixes i=1,4,6,12: drawdot (i,0) ; endfor}
599
600\stopsection
601
602\startsection[title={Graphics}]
603
604\index{graphics}
605
606\ShowSampleS {fm}
607  {loadfigure string number numeric ...}
608  {loadfigure "mycow.mp" number 1 scaled .25}
609
610\ShowSampleS {fm}
611  {externalfigure string ...}
612  {draw externalfigure "mycow.pdf" ysized 3cm}
613
614\ShowSampleT {fm} {addbackground text}
615  {addbackground withcolor .625 yellow}
616  {fill fullcircle xyscaled (2,1) InRed; addbackground InYellow}
617
618\ShowSampleQQ {mm} {image (text)}
619  {draw image(draw fullcircle) xscaled 4cm yscaled 1cm}
620
621\ShowSampleT {mm} {decorated (text) text}
622  {draw decorated (....) withcolor red}
623  {draw decorated (fill fullcircle) InRed}
624
625\ShowSampleT {mm} {undecorated (text) text}
626  {draw undecorated (.... withcolor yellow) withcolor red}
627  {draw undecorated (fill fullcircle InYellow) InRed}
628
629\ShowSampleT {mm} {redecorated (text) text}
630  {draw redecorated (.... withcolor yellow) withcolor red}
631  {draw redecorated (fill fullcircle InYellow) InRed}
632
633\ShowSampleS {mm}
634  {bitmapimage (w,h,data)}
635  {draw bitmapimage (2,2,"114477AA") rotated 15 scaled 4cm}
636
637\ShowSampleT {mm}
638  {withmask string}
639  {draw externalfigure "m-1.png" ysized 2cm withmask "m-2.png"}
640  {Scale := 1 ;
641   draw externalfigure "m-2.png" ysized 2cm shifted (-3cm,0) ;
642   draw externalfigure "m-1.png" ysized 2cm shifted (-6cm,0) ;
643   draw externalfigure "m-1.png" ysized 2cm withmask "m-2.png"}
644
645\stopsection
646
647\startsection[title={Access}]
648
649\ShowSampleW
650    {mm} {leftof  n}
651    {for i inpath fullcircle : drawdot leftof  i ; endfor}
652    {for i inpath fullcircle xsized 3cm: drawdot leftof  i withpen pencircle scaled 2mm InRed    ; endfor}
653\ShowSampleW
654    {mm} {pointof n}
655    {for i inpath fullcircle : drawdot pointof i ; endfor}
656    {for i inpath fullcircle xsized 3cm: drawdot pointof i withpen pencircle scaled 2mm InYellow ; endfor}
657\ShowSampleW
658    {mm} {rightof n}
659    {for i inpath fullcircle : drawdot rightof i ; endfor}
660    {for i inpath fullcircle xsized 3cm: drawdot rightof i withpen pencircle scaled 2mm InRed    ; endfor}
661
662\stopsection
663
664\stopchapter
665
666\stopcomponent
667
668%% draw leftpath  fullcircle scaled 1cm withpen pencircle scaled 1mm withcolor .625red ;
669%% draw reverse leftpath (reverse fullcircle scaled 2cm) withpen pencircle scaled 1mm withcolor .625yellow ;
670%% draw rightpath fullcircle scaled 3cm withpen pencircle scaled 1mm withcolor .625white ;
671%%
672%% path p ; p := (0,0) .. (1,2) .. cycle ;
673%% draw leftpath  p scaled 1cm withpen pencircle scaled 1mm withcolor .625red ;
674%% draw reverse leftpath (reverse p  scaled 2cm) withpen pencircle scaled 1mm withcolor .625yellow ;
675%% draw rightpath p  scaled 3cm  withpen pencircle scaled 1mm withcolor .625white ;
676