summaryrefslogtreecommitdiff
path: root/doc/context/sources/general
diff options
context:
space:
mode:
Diffstat (limited to 'doc/context/sources/general')
-rw-r--r--doc/context/sources/general/manuals/luametatex/luametatex-math.tex6
-rw-r--r--doc/context/sources/general/manuals/metafun/metafun-basics.tex2
-rw-r--r--doc/context/sources/general/manuals/metafun/metafun-effects.tex145
-rw-r--r--doc/context/sources/general/manuals/metafun/metafun-examples.tex37
-rw-r--r--doc/context/sources/general/manuals/metafun/metafun-introduction.tex11
-rw-r--r--doc/context/sources/general/manuals/metafun/metafun-lua.tex58
-rw-r--r--doc/context/sources/general/manuals/metafun/metafun-positioning.tex11
-rw-r--r--doc/context/sources/general/manuals/metafun/metafun-reference.tex1
-rw-r--r--doc/context/sources/general/manuals/metafun/metafun-text-lmtx.tex69
-rw-r--r--doc/context/sources/general/manuals/metafun/metafun-text.tex218
-rw-r--r--doc/context/sources/general/manuals/metafun/metafun-welcome.tex52
11 files changed, 364 insertions, 246 deletions
diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-math.tex b/doc/context/sources/general/manuals/luametatex/luametatex-math.tex
index 0261539da..37926c8ab 100644
--- a/doc/context/sources/general/manuals/luametatex/luametatex-math.tex
+++ b/doc/context/sources/general/manuals/luametatex/luametatex-math.tex
@@ -396,7 +396,7 @@ set the same:
\LL
\stoptabulate
-In addition there are \prm {UVextensible} and \prm {Uoperator} and extended
+In addition there are \prm {Uvextensible} and \prm {Uoperator} and extended
versions of fenced: \prm {Uleft}, \prm {Uright} and \prm {Umiddle}. There is also
\prm {Uover} and similar primitives that expect the numerator and denominator
after the primitive. In addition to regular scripts there are prescripts and a
@@ -1060,9 +1060,9 @@ defaults and tweak them in the goodie files:
\NC PrimeRaisePercent \NC \prm {Umathprimeraise} \NC 0 \NC \NR
\NC PrimeRaiseComposedPercent \NC \prm {Umathprimeraisecomposed} \NC 0 \NC \NR
\NC PrimeShiftUp \NC \prm {Umathprimeshiftup} \NC 0 \NC \NR
-\NC PrimeShiftUpCramped \NC \prm {Umathprimeshiftupcramped} \NC 0 \NC \NR
+\NC PrimeShiftUpCramped \NC \prm {Umathprimeshiftup} \NC 0 \NC \NR
\NC PrimeSpaceAfter \NC \prm {Umathprimespaceafter} \NC 0 \NC \NR
-\NC PrimeBaselineDropMax \NC \prm {Umathprimebaselinedropmax} \NC 0 \NC \NR
+\NC PrimeBaselineDropMax \NC \prm {Umathprimeshiftdrop} \NC 0 \NC \NR
\NC PrimeWidthPercent \NC \prm {Umathprimewidth} \NC 0 \NC \NR
\NC SkewedDelimiterTolerance \NC \prm {Umathskeweddelimitertolerance} \NC 0 \NC \NR
\NC AccentTopShiftUp \NC \prm {Umathaccenttopshiftup} \NC undefined \NC \NR
diff --git a/doc/context/sources/general/manuals/metafun/metafun-basics.tex b/doc/context/sources/general/manuals/metafun/metafun-basics.tex
index 02f208132..3eeefee22 100644
--- a/doc/context/sources/general/manuals/metafun/metafun-basics.tex
+++ b/doc/context/sources/general/manuals/metafun/metafun-basics.tex
@@ -1951,7 +1951,7 @@ the point and rotates afterwards. Because each consecutive point on the path is
rotated an additional 90 degrees, we use the \METAPOST\ macro \type {hide} to
isolate the assignment. The \type {hide} command executes the hidden command and
afterwards continues as if it were never there. You must not confuse this with
-grouping, since the hidden commands are visible to its surroundings.
+grouping, since the hidden commands are visible to their surroundings.
\startbuffer[c]
def qq = q hide(q := q rotated 90) enddef ;
diff --git a/doc/context/sources/general/manuals/metafun/metafun-effects.tex b/doc/context/sources/general/manuals/metafun/metafun-effects.tex
index 8a4d9c30c..b9d60e15b 100644
--- a/doc/context/sources/general/manuals/metafun/metafun-effects.tex
+++ b/doc/context/sources/general/manuals/metafun/metafun-effects.tex
@@ -232,9 +232,12 @@ path p ; p := fullcircle scaled u shifted (u/4,0);
% fill p rotated 210 withcolor transparent("\MPvar{a}",.5,xgreen) ;
% fill p rotated 330 withcolor transparent("\MPvar{a}",.5,xblue) ;
-fill p rotated 90 withcolor (0,0,1,0) withtransparency("\MPvar{a}",.5) ;
-fill p rotated 210 withcolor (0,1,0) withtransparency("\MPvar{a}",.5) ;
-fill p rotated 330 withcolor (0,0,1) withtransparency("\MPvar{a}",.5) ;
+% fill p rotated 90 withcolor (0,0,1,0) withtransparency("\MPvar{a}",.5) ;
+% fill p rotated 210 withcolor (0,1,0) withtransparency("\MPvar{a}",.5) ;
+% fill p rotated 330 withcolor (0,0,1) withtransparency("\MPvar{a}",.5) ;
+fill p rotated 90 withcolor (0,0,1,0) withtransparency(\MPvar{b},.5) ;
+fill p rotated 210 withcolor (0,1,0) withtransparency(\MPvar{b},.5) ;
+fill p rotated 330 withcolor (0,0,1) withtransparency(\MPvar{b},.5) ;
\stopuseMPgraphic
\startplacefigure[location=here,reference=fig:transparencies,title={The 12 transparency alternatives by name.}]
@@ -244,23 +247,22 @@ fill p rotated 330 withcolor (0,0,1) withtransparency("\MPvar{a}",.5) ;
\setupcombination[nx=4,ny=4]
}
\startcombination
- {\useMPgraphic{test}{a=normal}} {\tttf normal}
- % {\useMPgraphic{test}{a=multiply}} {\tttf multiply} % here the mu in multiply triggers lookahead in lmtx
- {\useMPgraphic{test}{a=2}} {\tttf multiply} % so we go for the numeric value instead (for now)
- {\useMPgraphic{test}{a=screen}} {\tttf screen}
- {\useMPgraphic{test}{a=overlay}} {\tttf overlay}
- {\useMPgraphic{test}{a=softlight}} {\tttf softlight}
- {\useMPgraphic{test}{a=hardlight}} {\tttf hardlight}
- {\useMPgraphic{test}{a=colordodge}} {\tttf colordodge}
- {\useMPgraphic{test}{a=colorburn}} {\tttf colorburn}
- {\useMPgraphic{test}{a=darken}} {\tttf darken}
- {\useMPgraphic{test}{a=lighten}} {\tttf lighten}
- {\useMPgraphic{test}{a=difference}} {\tttf difference}
- {\useMPgraphic{test}{a=exclusion}} {\tttf exclusion}
- {\useMPgraphic{test}{a=hue}} {\tttf hue}
- {\useMPgraphic{test}{a=saturation}} {\tttf saturation}
- {\useMPgraphic{test}{a=color}} {\tttf color}
- {\useMPgraphic{test}{a=luminosity}} {\tttf luminosity}
+ {\useMPgraphic{test}{b=1,a=normal}} {\tttf normal}
+ {\useMPgraphic{test}{b=2,a=multiply}} {\tttf multiply} % here the mu in multiply triggers lookahead in lmtx
+ {\useMPgraphic{test}{b=3,a=screen}} {\tttf screen}
+ {\useMPgraphic{test}{b=4,a=overlay}} {\tttf overlay}
+ {\useMPgraphic{test}{b=5,a=softlight}} {\tttf softlight}
+ {\useMPgraphic{test}{b=6,a=hardlight}} {\tttf hardlight}
+ {\useMPgraphic{test}{b=7,a=colordodge}} {\tttf colordodge}
+ {\useMPgraphic{test}{b=8,a=colorburn}} {\tttf colorburn}
+ {\useMPgraphic{test}{b=9,a=darken}} {\tttf darken}
+ {\useMPgraphic{test}{b=10,a=lighten}} {\tttf lighten}
+ {\useMPgraphic{test}{b=11,a=difference}} {\tttf difference}
+ {\useMPgraphic{test}{b=12,a=exclusion}} {\tttf exclusion}
+ {\useMPgraphic{test}{b=13,a=hue}} {\tttf hue}
+ {\useMPgraphic{test}{b=14,a=saturation}} {\tttf saturation}
+ {\useMPgraphic{test}{b=15,a=color}} {\tttf color}
+ {\useMPgraphic{test}{b=16,a=luminosity}} {\tttf luminosity}
\stopcombination
\stopplacefigure
@@ -2024,6 +2026,7 @@ suffix determines the number of arguments and rendering. The \type {r} suffix
reverses the order: the fill comes over the draw. There is a \type {p} suffix
that returns just the picture.
+
The next example demonstrates that you can combine \TEX's powerful line breaking
algorithm with \METAPOST's graphic capabilities.
@@ -2114,7 +2117,7 @@ width is half the size specified.
\startbuffer
draw outlinetext.b
- ("\mathematics{\left({{\sqrt{1+x}}\over{\sqrt{2+x^2}}}\right)}")
+ ("\mathematics{\left(\frac{\sqrt{1+x}}{\sqrt{2+x^2}}\right)}")
(withcolor .850white)
(withcolor .625red
dashed evenly scaled .1
@@ -2228,7 +2231,7 @@ and one with Dejavu (the Tufte quote).
\startcombination[1*4]
\bgroup
\def|#1|{-}%
- \definedfont[texgyrepagella-regular.otf*none]%
+ \definedfont[file:texgyrepagella-regular.otf*none]%
\startMPcode
draw outlinetext.b
("\framed[align=normal,width=max]{\input{zapf}}")
@@ -2238,7 +2241,7 @@ and one with Dejavu (the Tufte quote).
\egroup {pagella / no features}
\bgroup
\def|#1|{-}%
- \definedfont[texgyrepagella-regular.otf*default]%
+ \definedfont[file:texgyrepagella-regular.otf*default]%
\startMPcode
draw outlinetext.b
("\framed[align=normal,width=max]{\input{zapf}}")
@@ -2248,7 +2251,7 @@ and one with Dejavu (the Tufte quote).
\egroup {pagella / default features}
\bgroup
\def|#1|{-}%
- \definedfont[dejavuserif.ttf*none]%
+ \definedfont[file:dejavuserif.ttf*none]%
\startMPcode
draw outlinetext.b
("\framed[align=normal,width=max]{\input{tufte}}")
@@ -2258,7 +2261,7 @@ and one with Dejavu (the Tufte quote).
\egroup {dejavu serif / no features}
\bgroup
\def|#1|{-}%
- \definedfont[dejavuserif.ttf*default]%
+ \definedfont[file:dejavuserif.ttf*default]%
\startMPcode
draw outlinetext.b
("\framed[align=normal,width=max]{\input{tufte}}")
@@ -2309,7 +2312,7 @@ We start by defining the font:
script=hang,
language=kor]
-\definefont[KoreanFont][hanbatanglvt*korean-base]
+\definefont[KoreanFont][file:hanbatanglvt*korean-base]
\stopbuffer
\typebuffer \getbuffer
@@ -2318,52 +2321,52 @@ Next we define a macro that will draw the outline:
\startbuffer
\startMPdefinitions
- string KoreanColors[] ;
-
- KoreanColors[1] := "darkred" ;
- KoreanColors[2] := "darkgreen" ;
- KoreanColors[3] := "darkblue" ;
- KoreanColors[4] := "darkyellow" ;
- KoreanColors[5] := "darkgray" ;
-
- newinternal KoreanSplit ; KoreanSplit := -1 ;
- newinternal KoreanCode ; KoreanCode := -2 ;
- newinternal KoreanMode ; KoreanMode := KoreanSplit ;
-
- def KoreanOutline(expr txt) =
- picture p ; p := outlinetext.p(txt) ;
- numeric n ; n := 0 ;
- string old, new ; old := "" ;
- for i within p :
- if KoreanMode == KoreanSplit :
- n := n + 1 ;
- elseif KoreanMode == KoreanCode :
- new := prescriptpart i ;
- if new <> old :
- old := new ;
- n := n + 1 ;
- fi ;
- else :
- n := KoreanMode ;
- fi ;
- if unknown KoreanColors[n] :
- n := 1 ;
+string KoreanColors[] ;
+
+KoreanColors[1] := "darkred" ;
+KoreanColors[2] := "darkgreen" ;
+KoreanColors[3] := "darkblue" ;
+KoreanColors[4] := "darkyellow" ;
+KoreanColors[5] := "darkgray" ;
+
+newinternal KoreanSplit ; KoreanSplit := -1 ;
+newinternal KoreanCode ; KoreanCode := -2 ;
+newinternal KoreanMode ; KoreanMode := KoreanSplit ;
+
+def KoreanOutline(expr txt) =
+ picture p ; p := outlinetext.p(txt) ;
+ numeric n ; n := 0 ;
+ string old, new ; old := "" ;
+ for i within p :
+ if KoreanMode == KoreanSplit :
+ n := n + 1 ;
+ elseif KoreanMode == KoreanCode :
+ new := prescriptpart i ;
+ if new <> old :
+ old := new ;
+ n := n + 1 ;
fi ;
- draw pathpart i
- withpen pencircle scaled 1/10
- withcolor KoreanColors[n] ;
- endfor ;
- enddef ;
-
- def KoreanTest(expr txt) =
- image (
- KoreanMode := KoreanSplit ; KoreanOutline(txt) ;
- currentpicture := currentpicture shifted (- xpart urcorner currentpicture, 0);
- KoreanMode := KoreanCode ; KoreanOutline(txt) ;
- currentpicture := currentpicture shifted (- xpart urcorner currentpicture, 0);
- KoreanMode := 3 ; KoreanOutline(txt) ;
- )
- enddef ;
+ else :
+ n := KoreanMode ;
+ fi ;
+ if unknown KoreanColors[n] :
+ n := 1 ;
+ fi ;
+ draw pathpart i
+ withpen pencircle scaled 1/10
+ withcolor KoreanColors[n] ;
+ endfor ;
+enddef ;
+
+def KoreanTest(expr txt) =
+ image (
+ KoreanMode := KoreanSplit ; KoreanOutline(txt) ;
+ currentpicture := currentpicture shifted (- xpart urcorner currentpicture, 0);
+ KoreanMode := KoreanCode ; KoreanOutline(txt) ;
+ currentpicture := currentpicture shifted (- xpart urcorner currentpicture, 0);
+ KoreanMode := 3 ; KoreanOutline(txt) ;
+ )
+enddef ;
\stopMPdefinitions
\stopbuffer
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
diff --git a/doc/context/sources/general/manuals/metafun/metafun-introduction.tex b/doc/context/sources/general/manuals/metafun/metafun-introduction.tex
index def3c9a93..fb260e0f5 100644
--- a/doc/context/sources/general/manuals/metafun/metafun-introduction.tex
+++ b/doc/context/sources/general/manuals/metafun/metafun-introduction.tex
@@ -95,6 +95,17 @@ with the latest version; thanks to Otared Kavian for keeping an eye on that and
posting me possible issues. The real new features are part of what is to become
\LUAMETAFUN, but for that we have a separate manual.
+In 2022 Mikael Sundqvist and I spent a lot of time on improving math in both
+\LUAMETATEX\ and \CONTEXT\ \LMTX, which is now the main version. Because we're both
+\METAPOST\ fans we let ourselves being sidetracked to also explore new possibilities
+in the library. Some of the macros that evolved from that made it into \METAFUN\
+which is why we also discuss some here. Be aware of the fact that we do some things
+different in \LMTX\ than in \MKIV, for instance we moved to colors being specified
+as strings (references to colors defined in \CONTEXT). There are also some new
+features that are unique to the library in \LUAMETATEX, like \type {&&}, \type
+{&&&}, \type {&&&&} and \type {nocycle}. THis means that not everything discussed
+here works in \MKIV\ too.
+
\blank[big,samepage]
\startlines
diff --git a/doc/context/sources/general/manuals/metafun/metafun-lua.tex b/doc/context/sources/general/manuals/metafun/metafun-lua.tex
index e9e4b4a8d..a61fa43e5 100644
--- a/doc/context/sources/general/manuals/metafun/metafun-lua.tex
+++ b/doc/context/sources/general/manuals/metafun/metafun-lua.tex
@@ -1648,64 +1648,6 @@ but also nicely abstract ones.
% p = mp.getpath(name)
% \stoptyping
%
-% A is path a table of tables that have six values: the coordinates and the
-% pre- and postcontrol. You can manipulate this table and feed it back into
-% \METAPOST.
-%
-% \startlinecorrection
-% \startMPcode
-% numeric n ; n := lua.mp.newhash() ;
-%
-% for i=1 upto 3 :
-% lua.mp.tohash(n,i) ;
-% endfor ;
-%
-% fill fullcircle scaled 10mm withcolor
-% if lua.mp.inhash(n,3) : green else : red fi ;
-%
-% fill fullcircle scaled 5mm withcolor
-% if lua.mp.inhash(n,4) : green else : red fi ;
-%
-% lua.mp.disposehash(n)
-% \stopMPcode
-% \stoplinecorrection
-%
-% You can also store values with keys and access them later:
-%
-% \startlinecorrection
-% \startMPcode
-% numeric n ; n := lua.mp.newhash() ;
-%
-% for i=1 upto 3 :
-% lua.mp.tohash(n,i,decimal sqrt(i)) ;
-% endfor ;
-%
-% draw textext(lua.mp.fromhash(n,3))
-% ysized 1cm
-% withcolor blue ;
-%
-% lua.mp.disposehash(n)
-% \stopMPcode
-% \stoplinecorrection
-%
-% You can also name your own hash:
-%
-% \startlinecorrection
-% \startMPcode
-% lua.mp.newhash("foo") ;
-%
-% for i=1 upto 3 :
-% lua.mp.tohash("foo",i,decimal sqrt(i)) ;
-% endfor ;
-%
-% draw textext(lua.mp.fromhash("foo",2))
-% ysized 1cm
-% withcolor green ;
-%
-% lua.mp.disposehash("foo")
-% \stopMPcode
-% \stoplinecorrection
-%
% Although it might look like \METAPOST\ supports arrays the reality is that it
% doesn't really. There is a concept of suffixes but internally these are just a
% way to compose macros. The following test is one that is used in one of the
diff --git a/doc/context/sources/general/manuals/metafun/metafun-positioning.tex b/doc/context/sources/general/manuals/metafun/metafun-positioning.tex
index 5f18b3ee6..448dcd966 100644
--- a/doc/context/sources/general/manuals/metafun/metafun-positioning.tex
+++ b/doc/context/sources/general/manuals/metafun/metafun-positioning.tex
@@ -61,7 +61,7 @@ macro package reading this chapter only makes sense when you use \CONTEXT.
save pa, pb, pm, pab, na, nb, sa, sb ;
path pa, pb, pm, pab ; numeric na, nb ; string sa, sb ;
% the tags
- sa := texstr("from") ;
+ sa := texstr("from") ; % MPvars
sb := texstr("to") ;
% we need to check page crossing so we fetch the page numbers
na := positionpage(sa) ;
@@ -134,6 +134,7 @@ macro package reading this chapter only makes sense when you use \CONTEXT.
\startbuffer[box:1:also]
\startMPpositiongraphic{mpos:box}{fillcolor,linecolor,linewidth}
path box ; box := positionbox(texstr("self")) ;
+% path box ; box := positionbox("\MPvar{self}") ;
box := box enlarged texvar("filloffset") ;
fill box
withcolor texvar("fillcolor") ;
@@ -351,6 +352,7 @@ other tricks with positioning.
\startbuffer[g-circle]
\startMPpositiongraphic{mypos:circle}
path p ; p := positionbox(texstr("self")) ;
+% path p ; p := positionbox("\MPvar{self}") ;
p := fullcircle xsized (bbwidth(p)+4pt) shifted center p ;
pickup pencircle scaled 1pt ;
fill p withcolor .800white ;
@@ -362,8 +364,8 @@ other tricks with positioning.
\startbuffer[g-line]
\startMPpositiongraphic{mypos:line}
path pa, pb, pab ; numeric na, nb ; string ta, tb ;
- ta := texstr("from") ;
- tb := texstr("to") ;
+ ta := texstr("from") ; % "\MPvar{from}"
+ tb := texstr("to") ; % "\MPvar{to}"
na := positionpage(ta) ;
nb := positionpage(tb) ;
pa := positionbox(ta) ;
@@ -543,6 +545,7 @@ saw in the graphic:
\starttyping
path p ; p := positionbox(texstr("self")) ;
+% path p ; p := positionbox("\MPvar{self}") ;
\stoptyping
\type {texstr("self")} will return the current position, which, fed to \type
@@ -806,6 +809,8 @@ desktop.
\typebuffer
+\page
+
\startbuffer[demo]
\startbuffer
\setlayer [DemoLayer]
diff --git a/doc/context/sources/general/manuals/metafun/metafun-reference.tex b/doc/context/sources/general/manuals/metafun/metafun-reference.tex
index 847bc6565..947610323 100644
--- a/doc/context/sources/general/manuals/metafun/metafun-reference.tex
+++ b/doc/context/sources/general/manuals/metafun/metafun-reference.tex
@@ -470,6 +470,7 @@ defineshade cshade withshademethod "circular" ;
\ShowSampleII {mp} {dashed oddly} {dashed oddly}
\ShowSampleII {mp} {dashpattern} {dashed dashpattern (on .1 off .2 on .3 off .4)}
\ShowSampleII {mp} {undashed} {dashed evenly undashed}
+\ShowSampleII {fm} {withdashes pair} {withdashes (.1,.2)}
\ShowSampleJ {mm} {pencircle transform} {pencircle}
\ShowSampleJ {mm} {pensquare transform} {pensquare}
diff --git a/doc/context/sources/general/manuals/metafun/metafun-text-lmtx.tex b/doc/context/sources/general/manuals/metafun/metafun-text-lmtx.tex
index 6fa6b5da6..d6fb2bc23 100644
--- a/doc/context/sources/general/manuals/metafun/metafun-text-lmtx.tex
+++ b/doc/context/sources/general/manuals/metafun/metafun-text-lmtx.tex
@@ -1512,6 +1512,75 @@ The text and graphics come together in a framed text:
\stopsection
+\startsection[title=Hashes]
+
+\index {hashes}
+
+We can store data in a hash and access it later. Storage happens efficiently at the
+\LUA\ end.
+
+\startbuffer
+\startMPcode
+ tohash("foo","bar","gnu") ;
+ tohash("foo","rab","ung") ;
+ fill fullcircle scaled 1cm withcolor "lightgray" ;
+ draw textext(fromhash("foo","bar")) ;
+ draw textext(fromhash("foo","rab")) rotated 90 ;
+\stopMPcode
+\stopbuffer
+
+\typebuffer \startlinecorrection \getbuffer \stoplinecorrection
+
+With \type {newhash("foo")} we get back an index but this macro is only needed in
+\MKIV\ where. With \type {disposehash("foo")} a hash get wiped.
+
+\startbuffer
+\startMPcode
+ tohash(4,"bar","gnu") ;
+ tohash(4,"rab","ung") ;
+ fill fullcircle scaled 1cm withcolor "lightgray" ;
+ draw textext(fromhash(4,"bar")) ;
+ draw textext(fromhash(4,"rab")) rotated 90 ;
+\stopMPcode
+\stopbuffer
+
+\typebuffer \startlinecorrection \getbuffer \stoplinecorrection
+
+You can also used an indexed hash:
+
+\startbuffer
+\startMPcode
+ tohash("foo",1,"gnu") ;
+ tohash("foo",2,"ung") ;
+ fill fullcircle scaled 1cm withcolor "lightgray" ;
+ for i=1 upto 3 :
+ if inhash("foo",i) :
+ draw textext(fromhash("foo",i))
+ rotated ((i-1) * 90) ;
+ fi ;
+ endfor ;
+\stopMPcode
+\stopbuffer
+
+\typebuffer \startlinecorrection \getbuffer \stoplinecorrection
+
+And even booleans can be used as index:
+
+\startbuffer
+\startMPcode
+ tohash("foo",false,"gnu") ;
+ tohash("foo",true,"ung") ;
+ fill fullcircle scaled 1cm withcolor "lightgray" ;
+ draw textext(fromhash("foo",false)) ;
+ draw textext(fromhash("foo",true)) rotated 90 ;
+\stopMPcode
+\stopbuffer
+
+\typebuffer \startlinecorrection \getbuffer \stoplinecorrection
+
+
+\stopsection
+
\stopchapter
\stopcomponent
diff --git a/doc/context/sources/general/manuals/metafun/metafun-text.tex b/doc/context/sources/general/manuals/metafun/metafun-text.tex
index 5cebf549f..135fe7e35 100644
--- a/doc/context/sources/general/manuals/metafun/metafun-text.tex
+++ b/doc/context/sources/general/manuals/metafun/metafun-text.tex
@@ -708,118 +708,118 @@ In the examples, the text is typeset along the path with:
\startbuffer[draw]
\startuseMPgraphic{followtokens}
- path RotPath ; RotPath := fullcircle ;
+ path RotPath ; RotPath := fullcircle ;
\stopuseMPgraphic
\stopbuffer
- \startbuffer
- \typebuffer[draw]
- \startlinecorrection[blank]
- \hbox
- {\getbuffer[draw,toks]\hskip1cm
- \getbuffer[trac,draw,toks]}
- \stoplinecorrection
- \stopbuffer
-
- \getbuffer
-
- \startbuffer[draw]
- \startuseMPgraphic{followtokens}
- path RotPath ; RotPath := reverse fullcircle ;
- \stopuseMPgraphic
- \stopbuffer
-
- \getbuffer
-
- \startbuffer[draw]
- \startuseMPgraphic{followtokens}
- path RotPath ; RotPath := (-3cm,-1cm)--(0,1cm)--(3cm,-1cm) ;
- \stopuseMPgraphic
- \stopbuffer
-
- \getbuffer
-
- \startbuffer[draw]
- \startuseMPgraphic{followtokens}
- path RotPath ; RotPath := (-3cm,0)--(3cm,1cm) ;
- \stopuseMPgraphic
- \stopbuffer
-
- \getbuffer
-
- \startbuffer[draw]
- \startuseMPgraphic{followtokens}
- path RotPath ; RotPath := (-3cm,0)..(-1cm,1cm)..(3cm,0) ;
- \stopuseMPgraphic
- \stopbuffer
-
- \getbuffer
-
- \startbuffer[draw]
- \startuseMPgraphic{followtokens}
- path RotPath ; RotPath := (-3cm,0)..(-1cm,1cm)..(0cm,-2cm)..(3cm,0) ;
- \stopuseMPgraphic
- \stopbuffer
-
- \getbuffer
-
- When turned on, tracing will produce bounding boxes as well as draw the path.
- Tracing can be turned on by saying:
-
- \typebuffer[trac]
-
- % let's turn it off now
-
- \startMPinclusions
- boolean TraceRot ; TraceRot := false ;
- \stopMPinclusions
-
- The next example is dedicated to Giuseppe Bilotta who wants to handle multiple
- strings and uses a patched version of \type {\followtokens}. To avoid a
- complicated explanation, we will present an alternative here that uses overlays.
- This method also avoids complicated path definitions.
-
- \startbuffer
- \startoverlay
- {\startuseMPgraphic{followtokens}
- draw fullcircle scaled 5cm .
- withpen pencircle scaled 1pt withcolor .625yellow ;
- draw fullsquare scaled 5.25cm
- withpen pencircle scaled 1pt withcolor .625red ;
- drawoptions (withcolor .625red) ;
- path RotPath ; RotPath := halfcircle scaled 5cm ;
- setbounds currentpicture to boundingbox fullcircle scaled 5.25cm ;
- \stopuseMPgraphic
- \followtokens { Met{\`a} superiore }}
- {\startuseMPgraphic{followtokens}
- drawoptions (withcolor .625red) ;
- path RotPath ; RotPath := halfcircle rotated 90 scaled 5cm ;
- setbounds currentpicture to boundingbox fullcircle scaled 5.25cm ;
- \stopuseMPgraphic
- \followtokens { {$\star$} }}
- {\startuseMPgraphic{followtokens}
- drawoptions (withcolor .625red) ;
- path RotPath ; RotPath := halfcircle rotated 180 scaled 5cm ;
- setbounds currentpicture to boundingbox fullcircle scaled 5.25cm ;
- \stopuseMPgraphic
- \followtokens { Met{\`a} inferiore }}
- {\startuseMPgraphic{followtokens}
- drawoptions (withcolor .625red) ;
- path RotPath ; RotPath := halfcircle rotated 270 scaled 5cm ;
- setbounds currentpicture to boundingbox fullcircle scaled 5.25cm ;
- \stopuseMPgraphic
- \followtokens { {$\star$} }}
- \stopoverlay
- \stopbuffer
-
- \typebuffer
-
- In order to fool the overlay macro that each graphic has the same size, we force
- a bounding box.
-
- \startlinecorrection[blank]
- \getbuffer
- \stoplinecorrection
+\startbuffer
+\typebuffer[draw]
+\startlinecorrection[blank]
+\hbox
+ {\getbuffer[draw,toks]\hskip1cm
+ \getbuffer[trac,draw,toks]}
+\stoplinecorrection
+\stopbuffer
+
+\getbuffer
+
+\startbuffer[draw]
+\startuseMPgraphic{followtokens}
+ path RotPath ; RotPath := reverse fullcircle ;
+\stopuseMPgraphic
+\stopbuffer
+
+\getbuffer
+
+\startbuffer[draw]
+\startuseMPgraphic{followtokens}
+ path RotPath ; RotPath := (-3cm,-1cm)--(0,1cm)--(3cm,-1cm) ;
+\stopuseMPgraphic
+\stopbuffer
+
+\getbuffer
+
+\startbuffer[draw]
+\startuseMPgraphic{followtokens}
+ path RotPath ; RotPath := (-3cm,0)--(3cm,1cm) ;
+\stopuseMPgraphic
+\stopbuffer
+
+\getbuffer
+
+\startbuffer[draw]
+\startuseMPgraphic{followtokens}
+ path RotPath ; RotPath := (-3cm,0)..(-1cm,1cm)..(3cm,0) ;
+\stopuseMPgraphic
+\stopbuffer
+
+\getbuffer
+
+\startbuffer[draw]
+\startuseMPgraphic{followtokens}
+ path RotPath ; RotPath := (-3cm,0)..(-1cm,1cm)..(0cm,-2cm)..(3cm,0) ;
+\stopuseMPgraphic
+\stopbuffer
+
+\getbuffer
+
+When turned on, tracing will produce bounding boxes as well as draw the path.
+Tracing can be turned on by saying:
+
+\typebuffer[trac]
+
+% let's turn it off now
+
+\startMPinclusions
+ boolean TraceRot ; TraceRot := false ;
+\stopMPinclusions
+
+The next example is dedicated to Giuseppe Bilotta who wants to handle multiple
+strings and uses a patched version of \type {\followtokens}. To avoid a
+complicated explanation, we will present an alternative here that uses overlays.
+This method also avoids complicated path definitions.
+
+\startbuffer
+\startoverlay
+ {\startuseMPgraphic{followtokens}
+ draw fullcircle scaled 5cm .
+ withpen pencircle scaled 1pt withcolor .625yellow ;
+ draw fullsquare scaled 5.25cm
+ withpen pencircle scaled 1pt withcolor .625red ;
+ drawoptions (withcolor .625red) ;
+ path RotPath ; RotPath := halfcircle scaled 5cm ;
+ setbounds currentpicture to boundingbox fullcircle scaled 5.25cm ;
+ \stopuseMPgraphic
+ \followtokens { Met{\`a} superiore }}
+ {\startuseMPgraphic{followtokens}
+ drawoptions (withcolor .625red) ;
+ path RotPath ; RotPath := halfcircle rotated 90 scaled 5cm ;
+ setbounds currentpicture to boundingbox fullcircle scaled 5.25cm ;
+ \stopuseMPgraphic
+ \followtokens { {$\star$} }}
+ {\startuseMPgraphic{followtokens}
+ drawoptions (withcolor .625red) ;
+ path RotPath ; RotPath := halfcircle rotated 180 scaled 5cm ;
+ setbounds currentpicture to boundingbox fullcircle scaled 5.25cm ;
+ \stopuseMPgraphic
+ \followtokens { Met{\`a} inferiore }}
+ {\startuseMPgraphic{followtokens}
+ drawoptions (withcolor .625red) ;
+ path RotPath ; RotPath := halfcircle rotated 270 scaled 5cm ;
+ setbounds currentpicture to boundingbox fullcircle scaled 5.25cm ;
+ \stopuseMPgraphic
+ \followtokens { {$\star$} }}
+\stopoverlay
+\stopbuffer
+
+\typebuffer
+
+In order to fool the overlay macro that each graphic has the same size, we force
+a bounding box.
+
+\startlinecorrection[blank]
+\getbuffer
+\stoplinecorrection
\stopsection
diff --git a/doc/context/sources/general/manuals/metafun/metafun-welcome.tex b/doc/context/sources/general/manuals/metafun/metafun-welcome.tex
index a7b1715a7..90ceab730 100644
--- a/doc/context/sources/general/manuals/metafun/metafun-welcome.tex
+++ b/doc/context/sources/general/manuals/metafun/metafun-welcome.tex
@@ -2181,6 +2181,56 @@ The macro \type {drawoptions} provides you a way to set the default attributes.
drawoptions(dashed evenly withcolor red) ;
\stoptyping
+Dashes are pretty much bound to the backend in the sense that like line width
+they are a property that the \POSTSCRIPT\ (or actually nowadays the \PDF)
+interpreter handles. There is not that much cleverness involved at the \METAPOST\
+end. Take these examples:
+
+\startbuffer
+ pickup pencircle scaled 2mm ; path p ;
+
+ p := (0,0) {dir 25} .. (5cm,0) ;
+ draw p withcolor darkyellow ;
+ draw p dashed dashpattern (on 4mm off 3mm) withcolor darkblue ;
+ drawpoints point 0 of p withcolor white ;
+
+ p := ((0,0) {dir 70} .. {up} (5cm,0) .. cycle) yshifted -1cm ;
+ draw p withcolor darkyellow ;
+ draw p dashed dashpattern (on 4mm off 3mm) withcolor darkblue ;
+ drawpoints point 0 of p withcolor white ;
+\stopbuffer
+
+\typebuffer[a]
+
+\startlinecorrection[blank]
+\processMPbuffer
+\stoplinecorrection
+
+In both cases the dash is not evenly spread which for the line results in
+different begin and end rendering while the closed shape gets some weird looking
+connection. The next variant uses the \type {withdashes} macro that adapts the
+dashes to fit nicely to the path.
+
+\startbuffer[a]
+ pickup pencircle scaled 2mm ; path p ;
+
+ p := (0,0) {dir 25} .. (5cm,0) ;
+ draw p withcolor darkyellow ;
+ draw p withdashes (4mm,3mm) withcolor darkblue ;
+ drawpoints point 0 of p withcolor white ;
+
+ p := ((0,0) {dir 70} .. {up} (5cm,0) .. cycle) yshifted -1cm ;
+ draw p withcolor darkyellow ;
+ draw p withdashes (4mm,3mm) withcolor darkblue ;
+ drawpoints point 0 of p withcolor white ;
+\stopbuffer
+
+\typebuffer
+
+\startlinecorrection[blank]
+\processMPbuffer
+\stoplinecorrection
+
\stopsection
\startsection[reference=sec:text,title={Text}]
@@ -3164,7 +3214,7 @@ following line:
\startbuffer[b]
redraw currentpicture withpen pencircle scaled 2pt ;
-draw boundingbox currenpicture withpen pencircle scaled .5mm ;
+draw boundingbox currentpicture withpen pencircle scaled .5mm ;
\stopbuffer
\typebuffer[b]