summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/luametafun/luametafun-mesh-examples.tex
blob: 87f6d105fbefee6e6d93ec0a4dfe32cf2055249f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
\startbuffer[1]
\startuseMPgraphic{MyPath1}
    fill OverlayBox withcolor "darkyellow" ;
    save p ; path p[] ;
    p1 := unitsquare xysized( OverlayWidth/4, OverlayHeight/4) ;
    p2 := unitsquare xysized(2OverlayWidth/4,3OverlayHeight/5) shifted ( OverlayWidth/4,0) ;
    p3 := unitsquare xysized( OverlayWidth/4, OverlayHeight  ) shifted (3OverlayWidth/4,0) ;
    fill p1 withcolor "darkred" ;
    fill p2 withcolor "darkblue" ;
    fill p3 withcolor "darkgreen" ;
    draw lmt_mesh [ paths = { p1, p2, p3 } ] ;
    setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic
\stopbuffer

\startbuffer[2]
\startuseMPgraphic{MyPath2}
    save q ; path q ; q := unitcircle xysized(OverlayWidth,OverlayHeight) ;
    save p ; path p ; p := for i=1 upto length(q) :
        (center q) -- (point (i-1) of q) -- (point i of q) -- (center q) --
    endfor cycle ;
    fill q withcolor "darkgray" ;
    draw lmt_mesh [
        trace = true,
        paths = { p }
    ] withcolor "darkred" ;

    setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic
\stopbuffer

\startbuffer[3]
\startuseMPgraphic{MyPath3}
    save q ; path q ; q := unitcircle xysized(OverlayWidth,OverlayHeight) randomized 3mm ;
    fill q withcolor "darkgray" ;
    draw lmt_mesh [
        trace = true,
        paths = { meshed(q,OverlayBox,.05) }
    ] withcolor "darkgreen" ;
  % draw OverlayMesh(q,.025) withcolor "darkgreen" ;
    setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic
\stopbuffer

\startbuffer[4]
\startuseMPgraphic{MyPath4}
    save q ; path q ; q := unitcircle xysized(OverlayWidth,OverlayHeight) randomized 3mm ;
    fill q withcolor "darkgray" ;
    draw lmt_mesh [
        trace = true,
        auto  = true,
        step  = 0.0125,
        paths = { q }
    ] withcolor "darkyellow" ;
    setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic
\stopbuffer

\startbuffer[5]
\startuseMPgraphic{MyPath5}
    save q ; path q ; q := unitdiamond xysized(OverlayWidth,OverlayHeight) randomized 2mm ;
    q := q shifted - center q shifted center OverlayBox ;
    fill q withcolor "darkgray" ;
    draw lmt_mesh [
        trace = true,
        auto  = true,
        step  = 0.0125,
        paths = { q }
    ] withcolor "darkmagenta" ;
    setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic
\stopbuffer

\startbuffer[6]
\startuseMPgraphic{MyPath6}
    save p ; path p[] ;
    p1 := p2 := fullcircle xysized(2OverlayWidth/5,2OverlayHeight/3) ;
    p1 := p1 shifted - center p1 shifted center OverlayBox shifted (-1OverlayWidth/4,0) ;
    p2 := p2 shifted - center p2 shifted center OverlayBox shifted ( 1OverlayWidth/4,0) ;
    fill p1 withcolor "middlegray" ;
    fill p2 withcolor "middlegray" ;
    draw lmt_mesh [
        trace = true,
        auto  = true,
        step  = 0.02,
        paths = { p1, p2 }
    ] withcolor "darkcyan" ;
    setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic
\stopbuffer

\startbuffer[7]
\startuseMPgraphic{MyPath7}
    save p ; path p[] ;
    p1 := p2 := fullcircle xysized(2OverlayWidth/5,2OverlayHeight/3) rotated 45 ;
    p1 := p1 shifted - center p1 shifted center OverlayBox shifted (-1OverlayWidth/4,0) ;
    p2 := p2 shifted - center p2 shifted center OverlayBox shifted ( 1OverlayWidth/4,0) ;
    fill p1 withcolor "middlegray" ;
    fill p2 withcolor "middlegray" ;
    draw lmt_mesh [
        trace = true,
        auto  = true,
        step  = 0.01,
        box   = OverlayBox enlarged -5mm,
        paths = { p1, p2 }
    ] withcolor "darkcyan" ;
    draw OverlayBox enlarged -5mm withcolor "darkgray" ;
    setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic
\stopbuffer

\continueifinputfile {luametafun-mesh-examples.tex}

\setupbodyfont[dejavu]

\setupinteraction
  [state=start,
   color=white,
   contrastcolor=white]

\starttext

    \getbuffer[1,2,3,4,5,6,7]

    \defineoverlay[MyPath1][\useMPgraphic{MyPath1}]
    \defineoverlay[MyPath2][\useMPgraphic{MyPath2}]
    \defineoverlay[MyPath3][\useMPgraphic{MyPath3}]
    \defineoverlay[MyPath4][\useMPgraphic{MyPath4}]
    \defineoverlay[MyPath5][\useMPgraphic{MyPath5}]
    \defineoverlay[MyPath6][\useMPgraphic{MyPath6}]
    \defineoverlay[MyPath7][\useMPgraphic{MyPath7}]

    \startTEXpage
        \button[height=3cm,width=4cm,background=MyPath1,frame=off]{Example 1}[realpage(2)]
    \stopTEXpage

    \startTEXpage
        \button[height=3cm,width=4cm,background=MyPath2,frame=off]{Example 2}[realpage(3)]
    \stopTEXpage

    \startTEXpage
        \button[height=3cm,width=4cm,background=MyPath3,frame=off]{Example 3}[realpage(4)]
    \stopTEXpage

    \startTEXpage
        \button[height=3cm,width=4cm,background=MyPath4,frame=off]{Example 4}[realpage(5)]
    \stopTEXpage

    \startTEXpage
        \button[height=3cm,width=4cm,background=MyPath5,frame=off]{Example 5}[realpage(6)]
    \stopTEXpage

    \startTEXpage
        \button[height=3cm,width=4cm,background=MyPath6,frame=off]{Example 6}[realpage(7)]
    \stopTEXpage

    \startTEXpage
        \button[height=3cm,width=4cm,background=MyPath7,frame=off]{Example 7}[realpage(1)]
    \stopTEXpage

\stoptext