luametafun-mesh-examples.tex /size: 5150 b    last modification: 2021-10-28 13:50
1% language=us runpath=texruns:manuals/luametafun
2
3\startbuffer[1]
4\startuseMPgraphic{MyPath1}
5    fill OverlayBox withcolor "darkyellow" ;
6    save p ; path p[] ;
7    p1 := unitsquare xysized( OverlayWidth/4, OverlayHeight/4) ;
8    p2 := unitsquare xysized(2OverlayWidth/4,3OverlayHeight/5) shifted ( OverlayWidth/4,0) ;
9    p3 := unitsquare xysized( OverlayWidth/4, OverlayHeight  ) shifted (3OverlayWidth/4,0) ;
10    fill p1 withcolor "darkred" ;
11    fill p2 withcolor "darkblue" ;
12    fill p3 withcolor "darkgreen" ;
13    draw lmt_mesh [ paths = { p1, p2, p3 } ] ;
14    setbounds currentpicture to OverlayBox ;
15\stopuseMPgraphic
16\stopbuffer
17
18\startbuffer[2]
19\startuseMPgraphic{MyPath2}
20    save q ; path q ; q := unitcircle xysized(OverlayWidth,OverlayHeight) ;
21    save p ; path p ; p := for i=1 upto length(q) :
22        (center q) -- (point (i-1) of q) -- (point i of q) -- (center q) --
23    endfor cycle ;
24    fill q withcolor "darkgray" ;
25    draw lmt_mesh [
26        trace = true,
27        paths = { p }
28    ] withcolor "darkred" ;
29
30    setbounds currentpicture to OverlayBox ;
31\stopuseMPgraphic
32\stopbuffer
33
34\startbuffer[3]
35\startuseMPgraphic{MyPath3}
36    save q ; path q ; q := unitcircle xysized(OverlayWidth,OverlayHeight) randomized 3mm ;
37    fill q withcolor "darkgray" ;
38    draw lmt_mesh [
39        trace = true,
40        paths = { meshed(q,OverlayBox,.05) }
41    ] withcolor "darkgreen" ;
42  % draw OverlayMesh(q,.025) withcolor "darkgreen" ;
43    setbounds currentpicture to OverlayBox ;
44\stopuseMPgraphic
45\stopbuffer
46
47\startbuffer[4]
48\startuseMPgraphic{MyPath4}
49    save q ; path q ; q := unitcircle xysized(OverlayWidth,OverlayHeight) randomized 3mm ;
50    fill q withcolor "darkgray" ;
51    draw lmt_mesh [
52        trace = true,
53        auto  = true,
54        step  = 0.0125,
55        paths = { q }
56    ] withcolor "darkyellow" ;
57    setbounds currentpicture to OverlayBox ;
58\stopuseMPgraphic
59\stopbuffer
60
61\startbuffer[5]
62\startuseMPgraphic{MyPath5}
63    save q ; path q ; q := unitdiamond xysized(OverlayWidth,OverlayHeight) randomized 2mm ;
64    q := q shifted - center q shifted center OverlayBox ;
65    fill q withcolor "darkgray" ;
66    draw lmt_mesh [
67        trace = true,
68        auto  = true,
69        step  = 0.0125,
70        paths = { q }
71    ] withcolor "darkmagenta" ;
72    setbounds currentpicture to OverlayBox ;
73\stopuseMPgraphic
74\stopbuffer
75
76\startbuffer[6]
77\startuseMPgraphic{MyPath6}
78    save p ; path p[] ;
79    p1 := p2 := fullcircle xysized(2OverlayWidth/5,2OverlayHeight/3) ;
80    p1 := p1 shifted - center p1 shifted center OverlayBox shifted (-1OverlayWidth/4,0) ;
81    p2 := p2 shifted - center p2 shifted center OverlayBox shifted ( 1OverlayWidth/4,0) ;
82    fill p1 withcolor "middlegray" ;
83    fill p2 withcolor "middlegray" ;
84    draw lmt_mesh [
85        trace = true,
86        auto  = true,
87        step  = 0.02,
88        paths = { p1, p2 }
89    ] withcolor "darkcyan" ;
90    setbounds currentpicture to OverlayBox ;
91\stopuseMPgraphic
92\stopbuffer
93
94\startbuffer[7]
95\startuseMPgraphic{MyPath7}
96    save p ; path p[] ;
97    p1 := p2 := fullcircle xysized(2OverlayWidth/5,2OverlayHeight/3) rotated 45 ;
98    p1 := p1 shifted - center p1 shifted center OverlayBox shifted (-1OverlayWidth/4,0) ;
99    p2 := p2 shifted - center p2 shifted center OverlayBox shifted ( 1OverlayWidth/4,0) ;
100    fill p1 withcolor "middlegray" ;
101    fill p2 withcolor "middlegray" ;
102    draw lmt_mesh [
103        trace = true,
104        auto  = true,
105        step  = 0.01,
106        box   = OverlayBox enlarged -5mm,
107        paths = { p1, p2 }
108    ] withcolor "darkcyan" ;
109    draw OverlayBox enlarged -5mm withcolor "darkgray" ;
110    setbounds currentpicture to OverlayBox ;
111\stopuseMPgraphic
112\stopbuffer
113
114\continueifinputfile {luametafun-mesh-examples.tex}
115
116\setupbodyfont[dejavu]
117
118\setupinteraction
119  [state=start,
120   color=white,
121   contrastcolor=white]
122
123\starttext
124
125    \getbuffer[1,2,3,4,5,6,7]
126
127    \defineoverlay[MyPath1][\useMPgraphic{MyPath1}]
128    \defineoverlay[MyPath2][\useMPgraphic{MyPath2}]
129    \defineoverlay[MyPath3][\useMPgraphic{MyPath3}]
130    \defineoverlay[MyPath4][\useMPgraphic{MyPath4}]
131    \defineoverlay[MyPath5][\useMPgraphic{MyPath5}]
132    \defineoverlay[MyPath6][\useMPgraphic{MyPath6}]
133    \defineoverlay[MyPath7][\useMPgraphic{MyPath7}]
134
135    \startTEXpage
136        \button[height=3cm,width=4cm,background=MyPath1,frame=off]{Example 1}[realpage(2)]
137    \stopTEXpage
138
139    \startTEXpage
140        \button[height=3cm,width=4cm,background=MyPath2,frame=off]{Example 2}[realpage(3)]
141    \stopTEXpage
142
143    \startTEXpage
144        \button[height=3cm,width=4cm,background=MyPath3,frame=off]{Example 3}[realpage(4)]
145    \stopTEXpage
146
147    \startTEXpage
148        \button[height=3cm,width=4cm,background=MyPath4,frame=off]{Example 4}[realpage(5)]
149    \stopTEXpage
150
151    \startTEXpage
152        \button[height=3cm,width=4cm,background=MyPath5,frame=off]{Example 5}[realpage(6)]
153    \stopTEXpage
154
155    \startTEXpage
156        \button[height=3cm,width=4cm,background=MyPath6,frame=off]{Example 6}[realpage(7)]
157    \stopTEXpage
158
159    \startTEXpage
160        \button[height=3cm,width=4cm,background=MyPath7,frame=off]{Example 7}[realpage(1)]
161    \stopTEXpage
162
163\stoptext
164