math-mps-imp-demo.mkxl /size: 8925 b    last modification: 2025-02-21 11:03
1%D \module
2%D   [       file=math-mps-imp-demo,
3%D        version=2024.06.02,
4%D          title=\CONTEXT\ Math Macros,
5%D       subtitle=MathFun Demo,
6%D         author={Hans Hagen & Mikael Sundqvist},
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE & \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Math Macros / MathFun Demo}
15
16\unprotect
17
18\setupmathfraction[\s!vfrac]               [\c!mp=simplefun::math:default:00027]
19\setupmathradical [root]                   [\c!mp=simplefun::math:default:0221A]
20\setupmathaccent  [wideoverleftarrow]      [\c!mp=simplefun::math:default:020D6]
21\setupmathaccent  [wideoverrightarrow]     [\c!mp=simplefun::math:default:020D7]
22\setupmathaccent  [wideoverleftrightarrow] [\c!mp=simplefun::math:default:020E1]
23\setupmathaccent  [wideunderleftarrow]     [\c!mp=simplefun::math:default:020EE]
24\setupmathaccent  [wideunderrightarrow]    [\c!mp=simplefun::math:default:020EF]
25\setupmathaccent  [wideunderleftrightarrow][\c!mp=simplefun::math:default:0034D]
26
27\registermpextensible "00027 % division slash
28\registermpextensible "0221A % radical
29\registermpextensible "020D6 % over  left        arrow
30\registermpextensible "020D7 % over  right       arrow
31\registermpextensible "020E1 % over  left  right arrow
32\registermpextensible "020EE % under left        arrow
33\registermpextensible "020EF % under right       arrow
34\registermpextensible "0034D % under left  right arrow
35
36\setupmathfence   [bracket]                [\c!mp=simplefun::math:default]
37
38\registermpextensible "0005B % left  bracket
39\registermpextensible "0005D % right bracket
40\registermpextensible "0007C % bar
41\registermpextensible "023B4 % overbracket
42
43\startuseMPgraphic{simplefun::math:default:00027}
44    setbackendoption "noplugins" ;
45    picture p ; p := image (
46        draw (
47            (-4OverlayLineWidth,-OverlayDepth +OverlayMathAxis/2-OverlayLineWidth) --
48            ( 4OverlayLineWidth, OverlayHeight+OverlayMathAxis/2-OverlayLineWidth)
49        )
50            withpen pencircle scaled OverlayLineWidth
51        ;
52    ) ;
53    setbounds p to boundingbox p
54        leftenlarged  2OverlayLineWidth
55        rightenlarged 2OverlayLineWidth ;
56    draw p ;
57\stopuseMPgraphic
58
59\startuseMPgraphic{simplefun::math:default:0221A}
60    setbackendoption "noplugins" ;
61    draw (
62        (-OverlayHeight/2,OverlayHeight/2) --
63        (-OverlayHeight/4,-OverlayDepth) --
64        (0,OverlayHeight) --
65        (OverlayWidth,OverlayHeight) --
66        (OverlayWidth,OverlayHeight-OverlayHeight/10)
67    )
68        withpen pencircle scaled OverlayLineWidth
69    ;
70\stopuseMPgraphic
71
72\startuseMPgraphic{simplefun::math:default:020D6}
73    setbackendoption "noplugins" ;
74    drawarrow (OverlayWidth,OverlayHeight) -- (0,OverlayHeight)
75        withpen pencircle scaled OverlayLineWidth
76    ;
77\stopuseMPgraphic
78
79\startuseMPgraphic{simplefun::math:default:020D7}
80    setbackendoption "noplugins" ;
81    drawarrow (0,OverlayHeight) -- (OverlayWidth,OverlayHeight)
82        withpen pencircle scaled OverlayLineWidth
83    ;
84\stopuseMPgraphic
85
86\startuseMPgraphic{simplefun::math:default:020E1}
87    setbackendoption "noplugins" ;
88    drawdblarrow (0,OverlayHeight) -- (OverlayWidth,OverlayHeight)
89        withpen pencircle scaled OverlayLineWidth
90    ;
91\stopuseMPgraphic
92
93\startuseMPgraphic{simplefun::math:default:020EE}
94    setbackendoption "noplugins" ;
95    drawarrow (OverlayWidth,OverlayHeight) -- (0,OverlayHeight)
96        withpen pencircle scaled OverlayLineWidth
97    ;
98\stopuseMPgraphic
99
100\startuseMPgraphic{simplefun::math:default:020EF}
101    setbackendoption "noplugins" ;
102    drawarrow (0,OverlayHeight) -- (OverlayWidth,OverlayHeight)
103        withpen pencircle scaled OverlayLineWidth
104    ;
105\stopuseMPgraphic
106
107\startuseMPgraphic{simplefun::math:default:0034D}
108    setbackendoption "noplugins" ;
109    drawdblarrow (0,OverlayHeight) -- (OverlayWidth,OverlayHeight)
110        withpen pencircle scaled OverlayLineWidth
111    ;
112\stopuseMPgraphic
113
114\startuseMPgraphic{simplefun::math:default:0005B}
115    setbackendoption "noplugins" ;
116    picture p ; p := image (
117        draw (2OverlayLineWidth,-OverlayDepth) -- (0,-OverlayDepth) -- (0,OverlayHeight) -- (2OverlayLineWidth,OverlayHeight)
118            withpen pencircle scaled OverlayLineWidth
119        ;
120    ) ;
121    setbounds p to boundingbox p
122        leftenlarged  2OverlayLineWidth
123        rightenlarged 2OverlayLineWidth ;
124    draw p ;
125\stopuseMPgraphic
126
127\startuseMPgraphic{simplefun::math:default:0005D}
128    setbackendoption "noplugins" ;
129    picture p ; p := image (
130        draw (0,-OverlayDepth) -- (2OverlayLineWidth,-OverlayDepth) -- (2OverlayLineWidth,OverlayHeight) -- (0,OverlayHeight)
131            withpen pencircle scaled OverlayLineWidth
132        ;
133    ) ;
134    setbounds p to boundingbox p
135        leftenlarged  2OverlayLineWidth
136        rightenlarged 2OverlayLineWidth ;
137    draw p ;
138\stopuseMPgraphic
139
140\startuseMPgraphic{simplefun::math:default:0007C}
141    setbackendoption "noplugins" ;
142    picture p ; p := image (
143        draw (0,-OverlayDepth) -- (0,OverlayHeight)
144            withpen pencircle scaled OverlayLineWidth
145        ;
146    ) ;
147    setbounds p to boundingbox p
148        leftenlarged  2OverlayLineWidth
149        rightenlarged 2OverlayLineWidth ;
150    draw p ;
151\stopuseMPgraphic
152
153\startuseMPgraphic{simplefun::math:default:023B4}
154    setbackendoption "noplugins" ;
155    draw ((0,0) -- (0,4OverlayLineWidth) -- (OverlayWidth,4OverlayLineWidth) -- (OverlayWidth,0))
156        shifted (0,2OverlayLineWidth)
157        withpen pencircle scaled OverlayLineWidth
158    ;
159\stopuseMPgraphic
160
161\protect
162
163\continueifinputfile{math-mps-imp-demo.mkxl}
164
165\starttext
166
167% \usemathpluginlibrary[demo]
168
169% \starttyping
170% radical     : color [ symbolcolor | textcolor | numbercolor ]
171% fraction    : color [ symbolcolor | textcolor | [ topcolor | bottomcolor ]
172% accent      : color [ symbolcolor | textcolor ]
173% fence       : color [ symbolcolor | [leftcolor | rightcolor | middlecolor ] textcolor ]
174% operator    : color [ symbolcolor | textcolor | numbercolor [topcolor | bottomcolor ] ]
175% stacker     : color [ symbolcolor ]
176% \stoptyping
177
178\startTEXpage[offset=1TS]
179
180\im {
181    {      \vfrac[color=cyan]                 {1}{2}} +
182    {      \vfrac[symbolcolor=red,color=cyan] {1}{2}} +
183    {\blue \vfrac[symbolcolor=red]            {1}{2}} +
184    {\blue \vfrac[]                           {1}{2}} =
185    {      \vfrac[plugin=mp,symbolcolor=red]  {1}{2}} +
186    {\blue \vfrac[plugin=mp,symbolcolor=red]  {1}{2}} +
187    {\blue \vfrac[plugin=mp]                  {1}{2}}
188}
189
190\im {
191    {      \frac[color=cyan]                 {1}{2}} +
192    {      \frac[symbolcolor=red,color=cyan] {1}{2}} +
193    {\blue \frac[symbolcolor=red]            {1}{2}} +
194    {\blue \frac[]                           {1}{2}} =
195    {      \frac[plugin=mp,symbolcolor=red]  {1}{2}} +
196    {\blue \frac[plugin=mp,symbolcolor=red]  {1}{2}} +
197    {\blue \frac[plugin=mp]                  {1}{2}}
198}
199
200\im {
201    {      \sqrt[symbolcolor=red,color=cyan]        {x}}+
202    {\blue \sqrt[symbolcolor=red]                   {x}} +
203    {\blue \sqrt[]                                  {x}} =
204    {      \sqrt[plugin=mp,symbolcolor=red,color=cyan]{x}} +
205    {\blue \sqrt[plugin=mp,symbolcolor=red]           {x}} +
206    {\blue \sqrt[plugin=mp]                           {x}}
207}
208
209\im {
210    \widetilde[symbolcolor=blue,textcolor=green]{x+1} +
211    \widetilde[symbolcolor=blue,color=red]{x+1} +
212    \widetilde[color=cyan]{x+1}
213}
214
215\setupmathfence[bracket][symbolcolor=cyan,plugin=mp]
216
217\im {
218    \fenced[bracket]{x+1 \fence = 1} +
219    \fenced[bracket][symbolcolor=blue,color=red,middle=|]{x+1 \fence = 1} +
220    \fenced[bracket][symbolcolor=blue,color=red,middle=|,middlecolor=green]{x+1 \fence = 1} =
221    \fenced[bracket][plugin=mp,symbolcolor=blue,color=red,middle=|,middlecolor=green]{x+1 \fence = 1}
222}
223
224\im {
225    \integral[color=green,topcolor=blue,top=3,bottom=2]{x} +
226    \integral[symbolcolor=red,numbercolor=cyan,textcolor=green,bottom=\pi,top=\gamma]{x}
227}
228
229\im {
230    \wideoverleftarrow      [color=red]                  {x+1} +
231    \wideoverrightarrow     [plugin=mp,symbolcolor=red]  {x+1} +
232    \wideoverleftarrow      [plugin=mp,symbolcolor=blue] {x+1} +
233    \wideoverleftrightarrow [plugin=mp,color=red]        {x+1} =
234    \wideunderleftarrow     [color=red]                  {x+1} +
235    \wideunderleftarrow     [plugin=mp,symbolcolor=red]  {x+1} +
236    \wideunderleftarrow     [plugin=mp,symbolcolor=blue] {x+1} +
237    \wideunderleftrightarrow[plugin=mp,color=red]        {x+1}
238}
239
240\im {
241    \implies {x+1} +
242    \overbracket[symbolcolor=blue] {x+1} +
243    \overbracket[plugin=mp,mp=simplefun::math:default:023B4,symbolcolor=red] {x+1} +
244    \overbracket[plugin=mp,symbolcolor=red] {x+1}
245}
246
247% $x + \tupanddownarrows[color=red,leftcolor=green,rightcolor=blue]{left}{right} + x$
248
249\stopTEXpage
250
251\stoptext
252