diff options
author | Hans Hagen <pragma@wxs.nl> | 2023-01-04 12:09:26 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2023-01-04 12:09:26 +0100 |
commit | 705b807c950a697d3c8be592c452a6fb3e561c7e (patch) | |
tree | 82904661aca945d008f07deb568ee7f05b55df4f /doc/context/sources/general/manuals/metafun/metafun-examples.tex | |
parent | 62d980c99a617ff260f29ac2d3bdb084049f25b0 (diff) | |
download | context-705b807c950a697d3c8be592c452a6fb3e561c7e.tar.gz |
2023-01-04 11:35:00
Diffstat (limited to 'doc/context/sources/general/manuals/metafun/metafun-examples.tex')
-rw-r--r-- | doc/context/sources/general/manuals/metafun/metafun-examples.tex | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/doc/context/sources/general/manuals/metafun/metafun-examples.tex b/doc/context/sources/general/manuals/metafun/metafun-examples.tex index 20dc64dad..a0721103e 100644 --- a/doc/context/sources/general/manuals/metafun/metafun-examples.tex +++ b/doc/context/sources/general/manuals/metafun/metafun-examples.tex @@ -3515,6 +3515,43 @@ Again we demonstrate the differences with some examples. The result can be seen \stopsection +\startsection[title=Hidden beauty] + +\index {hiding} + +The \type {hide} wraps its (text) argument in a group in such a way that whatever +happens is not interfering with its surrounding. This is comparable with what +\type {vardef} does except that there is nothing of value produced. + +\startbuffer +def mfun_curve_to_a = hide(let connect = mfun_curve_to_b ;) enddef ; def mfun_curve_to_b = .. enddef ; +def mfun_line_to_a = hide(let connect = mfun_line_to_b ;) enddef ; def mfun_line_to_b = -- enddef ; + +def forcurve = hide(let connect = mfun_curve_to_a ;) for enddef; +def forline = hide(let connect = mfun_line_to_a ;) for enddef; + +draw image ( + draw forline i = 0 upto 25 : connect(i,sin(i)) endfor + withcolor darkblue + withtransparency (1,.5) ; + draw forcurve i = 0 upto 25 : connect(i,sin(i)) endfor + withcolor darkyellow + withtransparency (1,.5) ; +) xysized (TextWidth, 3cm) ; +\stopbuffer + +\typebuffer + +In this example we hide the assignment in the loop and not only define the \type +{connect} macro but also adept it after its first expansion. Usage is shown \in +{in } [fig:hide]. + +\startplacefigure[title=Hiding assignments in a loop,reference=fig:hide] + \processMPbuffer +\stopplacefigure + +\stopsection + \stopchapter \stopcomponent |