summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals
diff options
context:
space:
mode:
Diffstat (limited to 'doc/context/sources/general/manuals')
-rw-r--r--doc/context/sources/general/manuals/luametafun/luametafun-poisson.tex159
-rw-r--r--doc/context/sources/general/manuals/luametafun/luametafun.tex1
-rw-r--r--doc/context/sources/general/manuals/luametatex/luametatex-enhancements.tex47
-rw-r--r--doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex16
-rw-r--r--doc/context/sources/general/manuals/luametatex/luametatex-math.tex107
-rw-r--r--doc/context/sources/general/manuals/luametatex/luametatex-primitives.tex2
-rw-r--r--doc/context/sources/general/manuals/luametatex/luametatex-tex.tex7
7 files changed, 290 insertions, 49 deletions
diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-poisson.tex b/doc/context/sources/general/manuals/luametafun/luametafun-poisson.tex
new file mode 100644
index 000000000..cd4b6ddab
--- /dev/null
+++ b/doc/context/sources/general/manuals/luametafun/luametafun-poisson.tex
@@ -0,0 +1,159 @@
+% language=us
+
+\environment luametafun-style
+
+\startcomponent luametafun-poisson
+
+\startchapter[title={Poisson}]
+
+
+When, after a post on the \CONTEXT\ mailing list, Aditya pointed me to an article
+on mazes I ended up at poisson distributions which to me looks nicer than what I
+normally do, fill a grid and then randomize the resulting positions. With some
+hooks this can be used for interesting patterns too. The algorithm is based on
+the discussion at:
+
+\starttyping
+http://devmag.org.za/2009/05/03/poisson-disk-sampling
+\stoptyping
+
+Other websites mention some variants on that but I saw no reason to look into
+those in detail. I can imagine more random related variants in this domain so
+consider this an appetizer. The user is rather simple because some macro is
+assumed to deal with the rendering of the distributed points. We just show some
+examples (because the interface might evolve).
+
+\startbuffer
+\startMPcode
+ draw lmt_poisson [
+ width = 40,
+ height = 40,
+ distance = 1,
+ count = 20,
+ macro = "draw"
+ ] xsized 4cm ;
+\stopMPcode
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+\startlinecorrection
+ \getbuffer
+\stoplinecorrection
+
+\startbuffer
+\startMPcode
+ vardef tst (expr x, y, i, n) =
+ fill fullcircle scaled (10+10*(i/n)) shifted (10x,10y)
+ withcolor "darkblue" withtransparency (1,.5) ;
+ enddef ;
+
+ draw lmt_poisson [
+ width = 50,
+ height = 50,
+ distance = 1,
+ count = 20,
+ macro = "tst",
+ arguments = 4
+ ] xsized 6cm ;
+\stopMPcode
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+\startlinecorrection
+ \getbuffer
+\stoplinecorrection
+
+\startbuffer
+\startMPcode
+ vardef tst (expr x, y, i, n) =
+ fill fulldiamond scaled (5+5*(i/n)) randomized 2 shifted (10x,10y)
+ withcolor "darkgreen" ;
+ enddef ;
+
+ draw lmt_poisson [
+ width = 50,
+ height = 50,
+ distance = 1,
+ count = 20,
+ macro = "tst",
+ initialx = 10,
+ initialy = 10,
+ arguments = 4
+ ] xsized 6cm ;
+\stopMPcode
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+\startlinecorrection
+ \getbuffer
+\stoplinecorrection
+
+\startbuffer
+\startMPcode{doublefun}
+ vardef tst (expr x, y, i, n) =
+ fill fulldiamond randomized (.2*i/n) shifted (x,y);
+ enddef ;
+
+ draw lmt_poisson [
+ width = 150,
+ height = 150,
+ distance = 1,
+ count = 20,
+ macro = "tst",
+ arguments = 4
+ ] xsized 6cm withcolor "darkmagenta" ;
+\stopMPcode
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+\startlinecorrection
+ \getbuffer
+\stoplinecorrection
+
+\startbuffer
+\startMPcode
+ vardef tst (expr x, y, i, n) =
+ draw externalfigure "cow.pdf" ysized (10+5*i/n) shifted (10x,10y);
+ enddef ;
+ draw lmt_poisson [
+ width = 20,
+ height = 20,
+ distance = 1,
+ count = 20,
+ macro = "tst"
+ arguments = 4,
+ ] xsized 6cm ;
+\stopMPcode
+\stopbuffer
+
+\typebuffer[option=TEX]
+
+\startlinecorrection
+ \getbuffer
+\stoplinecorrection
+
+The supported parameters are:
+
+\starttabulate[|T|T|T|p|]
+\FL
+\BC name \BC type \BC default \BC comment \NC \NR
+\ML
+\NC width \NC numeric \NC 50 \NC \NC \NR
+\NC height \NC numeric \NC 50 \NC \NC \NR
+\NC distance \NC numeric \NC 1 \NC \NC \NR
+\NC count \NC numeric \NC 20 \NC \NC \NR
+\NC macro \NC string \NC "draw" \NC \NC \NR
+\NC initialx \NC numeric \NC 10 \NC \NC \NR
+\NC initialy \NC numeric \NC 10 \NC \NC \NR
+\NC arguments \NC numeric \NC 4 \NC \NC \NR
+\LL
+\stoptabulate
+
+\stopchapter
+
+\stopcomponent
+
diff --git a/doc/context/sources/general/manuals/luametafun/luametafun.tex b/doc/context/sources/general/manuals/luametafun/luametafun.tex
index 2dd917cdf..a75e3d541 100644
--- a/doc/context/sources/general/manuals/luametafun/luametafun.tex
+++ b/doc/context/sources/general/manuals/luametafun/luametafun.tex
@@ -26,6 +26,7 @@
\component luametafun-function
\component luametafun-chart
\component luametafun-svg
+ \component luametafun-poisson
\component luametafun-fonts
\component luametafun-groups
\component luametafun-interface
diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-enhancements.tex b/doc/context/sources/general/manuals/luametatex/luametatex-enhancements.tex
index cc3788ee9..3e710fe8c 100644
--- a/doc/context/sources/general/manuals/luametatex/luametatex-enhancements.tex
+++ b/doc/context/sources/general/manuals/luametatex/luametatex-enhancements.tex
@@ -565,6 +565,53 @@ tokens and assume that the function is available when that token expands. On the
other hand, as we have tested this functionality in relative complex situations
normal usage should not give problems.
+There are another three (still experimental) primitives that behave like \lpr
+{luafunction} but they expect the function to return an integer, dimension (also
+an integer) or a gluespec node. The return values gets injected into the input.
+
+\starttyping
+\luacountfunction 997 123
+\luadimenfunction 998 123pt
+\luaskipfunction 999 123pt plus 10pt minus 20pt
+\stoptyping
+
+Examples of function 997 in the above lines are:
+
+\starttyping
+function() return token.scan_int() end
+function() return 1234 end
+\stoptyping
+
+This itself is not spectacular so there is more. These functions can be called in
+two modes: either \TEX\ is expecting a value, or it is not and just expanding the
+call.
+
+\starttyping
+local n = 0
+function(slot,scanning)
+ if scanning then
+ return n
+ else
+ n = token.scan_int()
+ end
+end
+\stoptyping
+
+So, assuming that the function is in slot 997, you can do this:
+
+\starttyping
+\luacountfunction 997 123
+\count100=\luacountfunction 997
+\stoptyping
+
+After which \type {\count 100} has the value \type {123}.
+
+% Also experimental (I need to play with this a bit more when I have time):
+%
+% The \type {token.set_lua} function already accepts some strings as optional
+% arguments (\type {protected} and \type {global}) and now also handles \type
+% {count}, \type {dimen} and \type {skip}.
+
\stopsubsection
\startsubsection[title={\lpr {luabytecode} and \lpr {luabytecodecall}}]
diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex b/doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex
index 2edf06f3e..bff3191d1 100644
--- a/doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex
+++ b/doc/context/sources/general/manuals/luametatex/luametatex-fonts.tex
@@ -391,17 +391,19 @@ expansion takes place inside the argument.
\fontid\font
\stopsyntax
-This primitive expands into a number. It is not a register so there is no need to
-prefix with \prm {number} (and using \prm {the} gives an error). The currently
-used font id is \fontid\font. Here are some more:
+This primitive expands into a number. The currently used font id is
+\number\fontid\font. Here are some more: \footnote {Contrary to \LUATEX\ this is
+now a number so you need to use \type {\number} or \type {\the}. The same is true
+for some other numbers and dimensions that for some reason ended up in the
+serializer that produced a sequence of tokens.}
\starttabulate[|l|c|c|]
\DB style \BC command \BC font id \NC \NR
\TB
-\NC normal \NC \type {\tf} \NC \tf \fontid\font \NC \NR
-\NC bold \NC \type {\bf} \NC \bf \fontid\font \NC \NR
-\NC italic \NC \type {\it} \NC \it \fontid\font \NC \NR
-\NC bold italic \NC \type {\bi} \NC \bi \fontid\font \NC \NR
+\NC normal \NC \type {\tf} \NC \tf \number\fontid\font \NC \NR
+\NC bold \NC \type {\bf} \NC \bf \number\fontid\font \NC \NR
+\NC italic \NC \type {\it} \NC \it \number\fontid\font \NC \NR
+\NC bold italic \NC \type {\bi} \NC \bi \number\fontid\font \NC \NR
\LL
\stoptabulate
diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-math.tex b/doc/context/sources/general/manuals/luametatex/luametatex-math.tex
index 407bb8cb5..3e7ea1840 100644
--- a/doc/context/sources/general/manuals/luametatex/luametatex-math.tex
+++ b/doc/context/sources/general/manuals/luametatex/luametatex-math.tex
@@ -143,7 +143,8 @@ It is possible to discover the math style that will be used for a formula in an
expandable fashion (while the math list is still being read). To make this
possible, \LUATEX\ adds the new primitive: \lpr {mathstyle}. This is a \quote
{convert command} like e.g. \prm {romannumeral}: its value can only be read,
-not set.
+not set. Beware that contrary to \LUATEX\ this is now a proper number so you need
+to use \type {\number} o r\type {\the} in order to serialize it.
The returned value is between 0 and 7 (in math mode), or $-1$ (all other modes).
For easy testing, the eight math style commands have been altered so that they can
@@ -178,55 +179,55 @@ differ from the used style (second pass). In the case of a math choice used
ungrouped, the chosen style is used after the choice too, unless you group.
\startbuffer[1]
- [a:\mathstyle]\quad
+ [a:\number\mathstyle]\quad
\bgroup
\mathchoice
- {\bf \scriptstyle (x:d :\mathstyle)}
- {\bf \scriptscriptstyle (x:t :\mathstyle)}
- {\bf \scriptscriptstyle (x:s :\mathstyle)}
- {\bf \scriptscriptstyle (x:ss:\mathstyle)}
+ {\bf \scriptstyle (x:d :\number\mathstyle)}
+ {\bf \scriptscriptstyle (x:t :\number\mathstyle)}
+ {\bf \scriptscriptstyle (x:s :\number\mathstyle)}
+ {\bf \scriptscriptstyle (x:ss:\number\mathstyle)}
\egroup
- \quad[b:\mathstyle]\quad
+ \quad[b:\number\mathstyle]\quad
\mathchoice
- {\bf \scriptstyle (y:d :\mathstyle)}
- {\bf \scriptscriptstyle (y:t :\mathstyle)}
- {\bf \scriptscriptstyle (y:s :\mathstyle)}
- {\bf \scriptscriptstyle (y:ss:\mathstyle)}
- \quad[c:\mathstyle]\quad
+ {\bf \scriptstyle (y:d :\number\mathstyle)}
+ {\bf \scriptscriptstyle (y:t :\number\mathstyle)}
+ {\bf \scriptscriptstyle (y:s :\number\mathstyle)}
+ {\bf \scriptscriptstyle (y:ss:\number\mathstyle)}
+ \quad[c:\number\mathstyle]\quad
\bgroup
\mathchoice
- {\bf \scriptstyle (z:d :\mathstyle)}
- {\bf \scriptscriptstyle (z:t :\mathstyle)}
- {\bf \scriptscriptstyle (z:s :\mathstyle)}
- {\bf \scriptscriptstyle (z:ss:\mathstyle)}
+ {\bf \scriptstyle (z:d :\number\mathstyle)}
+ {\bf \scriptscriptstyle (z:t :\number\mathstyle)}
+ {\bf \scriptscriptstyle (z:s :\number\mathstyle)}
+ {\bf \scriptscriptstyle (z:ss:\number\mathstyle)}
\egroup
- \quad[d:\mathstyle]
+ \quad[d:\number\mathstyle]
\stopbuffer
\startbuffer[2]
- [a:\mathstyle]\quad
+ [a:\number\mathstyle]\quad
\begingroup
\mathchoice
- {\bf \scriptstyle (x:d :\mathstyle)}
- {\bf \scriptscriptstyle (x:t :\mathstyle)}
- {\bf \scriptscriptstyle (x:s :\mathstyle)}
- {\bf \scriptscriptstyle (x:ss:\mathstyle)}
+ {\bf \scriptstyle (x:d :\number\mathstyle)}
+ {\bf \scriptscriptstyle (x:t :\number\mathstyle)}
+ {\bf \scriptscriptstyle (x:s :\number\mathstyle)}
+ {\bf \scriptscriptstyle (x:ss:\number\mathstyle)}
\endgroup
- \quad[b:\mathstyle]\quad
+ \quad[b:\number\mathstyle]\quad
\mathchoice
- {\bf \scriptstyle (y:d :\mathstyle)}
- {\bf \scriptscriptstyle (y:t :\mathstyle)}
- {\bf \scriptscriptstyle (y:s :\mathstyle)}
- {\bf \scriptscriptstyle (y:ss:\mathstyle)}
- \quad[c:\mathstyle]\quad
+ {\bf \scriptstyle (y:d :\number\mathstyle)}
+ {\bf \scriptscriptstyle (y:t :\number\mathstyle)}
+ {\bf \scriptscriptstyle (y:s :\number\mathstyle)}
+ {\bf \scriptscriptstyle (y:ss:\number\mathstyle)}
+ \quad[c:\number\mathstyle]\quad
\begingroup
\mathchoice
- {\bf \scriptstyle (z:d :\mathstyle)}
- {\bf \scriptscriptstyle (z:t :\mathstyle)}
- {\bf \scriptscriptstyle (z:s :\mathstyle)}
- {\bf \scriptscriptstyle (z:ss:\mathstyle)}
+ {\bf \scriptstyle (z:d :\number\mathstyle)}
+ {\bf \scriptscriptstyle (z:t :\number\mathstyle)}
+ {\bf \scriptscriptstyle (z:s :\number\mathstyle)}
+ {\bf \scriptscriptstyle (z:ss:\number\mathstyle)}
\endgroup
- \quad[d:\mathstyle]
+ \quad[d:\number\mathstyle]
\stopbuffer
\typebuffer[1]
@@ -734,7 +735,7 @@ marked \type {*} in the \TEX book. These will not actually be used as those
combinations of atoms cannot actually happen, but it seemed better not to break
orthogonality. They are initialized to zero.
-\subsection{Local settings}
+\subsection{Local \lpr {frozen} settings with}
Math is processed in two passes. The first pass is needed to intercept for
instance \type {\over}, one of the few \TEX\ commands that actually has a
@@ -775,7 +776,25 @@ unprocessed math list. The result looks as follows:
\blank \getbuffer \blank
+\subsection{Checking a state with \lpr {Umathparameter}}
+When you adapt math parameters it might make sense to see if they are set at
+all. When a parameter is unset its value has the maximum dimension value and
+you might for instance mistakenly multiply that value to open up things a bit,
+which gives unexpected side effects. For that reason there is a convenient
+checker: \lpr {Umathparameter}. When followed by a valid parameter it expands
+to a state number:
+
+: 0=zero, 1=set, 2=unset (les stracing clutter this way)
+
+\starttabulate[|c|l|]
+\DB value \BC meaning \NC \NR
+\TB
+\NC 0 \NC the parameter value is zero \NC \NR
+\NC 1 \NC the parameter is set \NC \NR
+\NC 2 \NC the parameter is unset \NC \NR
+\LL
+\stoptabulate
\subsection{Skips around display math and \lpr {mathdisplayskipmode}}
@@ -788,7 +807,7 @@ to fully control spacing. Therefore \LUATEX\ comes with a new directive: \lpr
{mathdisplayskipmode}. The following values apply:
\starttabulate[|c|l|]
-\DB value \BC meaning \NC \NR
+\DB value \BC meaning \NC \NR
\TB
\NC 0 \NC normal \TEX\ behaviour \NC \NR
\NC 1 \NC always (same as 0) \NC \NR
@@ -1441,9 +1460,9 @@ zero upto seven (like the ones reported by the primitive \lpr {mathstyle}). So,
next few lines give identical results:
\startbuffer
-$\Ustyle0 \mathstyle \Ustyle7 \mathstyle$
-$\Ustyle\displaystyle \mathstyle \Ustyle\crampedscriptscriptstyle \mathstyle$
-$ \displaystyle \mathstyle \crampedscriptscriptstyle \mathstyle$
+$\Ustyle0 \number\mathstyle \Ustyle7 \number\mathstyle$
+$\Ustyle\displaystyle \number\mathstyle \Ustyle\crampedscriptscriptstyle \number\mathstyle$
+$ \displaystyle \number\mathstyle \crampedscriptscriptstyle \number\mathstyle$
\stopbuffer
Like: \inlinebuffer . Values outside the valid range are ignored.
@@ -1528,9 +1547,15 @@ These commands are provided as convenience. Before they come available you could
do the following:
\starttyping
-\def\Umathcharclass{\directlua{tex.print(tex.getmathcode(token.scan_int())[1])}}
-\def\Umathcharfam {\directlua{tex.print(tex.getmathcode(token.scan_int())[2])}}
-\def\Umathcharslot {\directlua{tex.print(tex.getmathcode(token.scan_int())[3])}}
+\def\Umathcharclass{\numexpr
+ \directlua{tex.print(tex.getmathcode(token.scan_int())[1])}
+\relax}
+\def\Umathcharfam{\numexpr
+ \directlua{tex.print(tex.getmathcode(token.scan_int())[2])}
+\relax}
+\def\Umathcharslot{\numexpr
+ \directlua{tex.print(tex.getmathcode(token.scan_int())[3])}
+\relax}
\stoptyping
\subsection {Last lines and \lpr{predisplaygapfactor}}
diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-primitives.tex b/doc/context/sources/general/manuals/luametatex/luametatex-primitives.tex
index 187bbd85a..825de3e12 100644
--- a/doc/context/sources/general/manuals/luametatex/luametatex-primitives.tex
+++ b/doc/context/sources/general/manuals/luametatex/luametatex-primitives.tex
@@ -339,7 +339,7 @@ new primitives, a summary is given below.
\NC \type {wordboundary} \NC command \NC \NC \NR
\NC \type {nohrule} \NC command \NC \NC \NR
\NC \type {novrule} \NC command \NC \NC \NR
-\NC \type {insertht} \NC number \NC \NC \NR
+\NC \type {insertht} \NC dimension \NC \NC \NR
\NC \type {quitvmode} \NC command \NC \NC \NR
\NC \type {leftmarginkern} \NC dimension \NC \NC \NR
\NC \type {rightmarginkern} \NC dimension \NC \NC \NR
diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-tex.tex b/doc/context/sources/general/manuals/luametatex/luametatex-tex.tex
index 09c4233a0..56fffeafa 100644
--- a/doc/context/sources/general/manuals/luametatex/luametatex-tex.tex
+++ b/doc/context/sources/general/manuals/luametatex/luametatex-tex.tex
@@ -390,6 +390,10 @@ These are read|-|only:
tex.deadcycles
tex.insertpenalties
tex.parshape
+tex.interlinepenalties
+tex.clubpenalties
+tex.widowpenalties
+tex.displaywidowpenalties
tex.prevgraf
tex.spacefactor
\stoptyping
@@ -2071,6 +2075,9 @@ most intriguing.
\LL
\stoptabulate
+The integer, dimension and glue scanners take an extra optional argument that
+signals that en optional equal is permitted.
+
The scanners can be considered stable apart from the one scanning for a token.
The \type {scan_code} function takes an optional number, the \type {scan_keyword}
function a normal \LUA\ string. The \type {infinity} boolean signals that we also