diff options
Diffstat (limited to 'doc/context/sources/general/manuals/luametafun')
22 files changed, 3316 insertions, 0 deletions
diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-arrow.tex b/doc/context/sources/general/manuals/luametafun/luametafun-arrow.tex new file mode 100644 index 000000000..72c9528e8 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-arrow.tex @@ -0,0 +1,166 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-arrow + +\startchapter[title={Arrow}] + +Arrows are somewhat complicated because they follow the path, are constructed +using a pen, have a fill and draw, and need to scale. One problem is that the +size depends on the pen but the pen normally is only known afterwards. + +\startbuffer[1a] +\startMPcode +draw lmt_arrow [ + path = (fullcircle scaled 3cm), +] + withpen pencircle scaled 2mm + withcolor "darkred" ; +\stopMPcode +\stopbuffer + +\startbuffer[1b] +\startMPcode +draw lmt_arrow [ + path = (fullcircle scaled 3cm), + length = 8, +] + withpen pencircle scaled 2mm + withcolor "darkgreen" ; +\stopMPcode +\stopbuffer + +\startbuffer[1c] +\startMPcode +draw lmt_arrow [ + path = (fullcircle scaled 3cm rotated 45), + pen = (pencircle xscaled 2mm yscaled 1mm rotated 45), +] + withpen pencircle xscaled 2mm yscaled 1mm rotated 45 + withcolor "darkblue" ; +\stopMPcode +\stopbuffer + +\startbuffer[1d] +\startMPcode +pickup pencircle xscaled 2mm yscaled 1mm rotated 45 ; +draw lmt_arrow [ + path = (fullcircle scaled 3cm rotated 45), + pen = "auto", +] + withcolor "darkyellow" ; +\stopMPcode +\stopbuffer + +To some extent \METAFUN\ can help you with this issue. In \in {figure} [arrows:1] +we see some variants. The definitions are given below: + +\typebuffer[1a][option=TEX] +\typebuffer[1b][option=TEX] +\typebuffer[1c][option=TEX] +\typebuffer[1d][option=TEX] + +\startplacefigure[reference=arrows:1] + \startcombination[4*1] + {\getbuffer[1a]} {default} + {\getbuffer[1b]} {length} + {\getbuffer[1c]} {pen} + {\getbuffer[1d]} {auto} + \stopcombination +\stopplacefigure + +There are some options that influence the shape of the arrowhead and its +location on the path. You can for instance ask for two arrowheads: + +\startbuffer[3] +\startMPcode + pickup pencircle scaled 1mm ; + draw lmt_arrow [ + pen = "auto", + location = "both" + path = fullcircle scaled 3cm rotated 90, + ] withcolor "darkgreen" ; +\stopMPcode +\stopbuffer + +\typebuffer[3][option=TEX] + +\startlinecorrection +\getbuffer[3] +\stoplinecorrection + +The shape can also be influenced although often this is not that visible: + +\startbuffer[4] +\startMPcode + pickup pencircle scaled 1mm ; + draw lmt_arrow [ + kind = "draw", + pen = "auto", + penscale = 4, + location = "middle", + alternative = "curved", + path = fullcircle scaled 3cm, + ] withcolor "darkblue" ; +\stopMPcode +\stopbuffer + +\typebuffer[4][option=TEX] + +\startlinecorrection +\getbuffer[4] +\stoplinecorrection + +The location can also be given as percentage, as this example demonstrates. Watch +how we draw only arrow heads: + +\startbuffer[5] +\startMPcode + pickup pencircle scaled 1mm ; + for i = 0 step 5 until 100 : + draw lmt_arrow [ + alternative = "dimpled", + pen = "auto", + location = "percentage", + percentage = i, + dimple = (1/5 + i/200), + headonly = (i = 0), + path = fullcircle scaled 3cm, + ] withcolor "darkyellow" ; + endfor ; +\stopMPcode +\stopbuffer + +\typebuffer[5][option=TEX] + +\startlinecorrection +\getbuffer[5] +\stoplinecorrection + +The supported parameters are: + +\starttabulate[|T|T|T|p|] +\FL +\BC name \BC type \BC default \BC comment \NC \NR +\ML +\NC path \NC path \NC \NC \NC \NR +\NC pen \NC path \NC \NC \NC \NR +\NC \NC string \NC auto \NC \NC \NR +\NC kind \NC string \NC fill \NC \type {fill} or \type {draw} \NC \NR +\NC dimple \NC numeric \NC 1/5 \NC \NC \NR +\NC scale \NC numeric \NC 3/4 \NC \NC \NR +\NC penscale \NC numeric \NC 3 \NC \NC \NR +\NC length \NC numeric \NC 4 \NC \NC \NR +\NC angle \NC numeric \NC 45 \NC \NC \NR +\NC location \NC string \NC end \NC \type {end}, \type {middle} or \type {both} \NC \NR % middle both +\NC alternative \NC string \NC normal \NC \type {normal}, \type {dimpled} or \type {curved} \NC \NR +\NC percentage \NC numeric \NC 50 \NC \NC \NR +\NC headonly \NC boolean \NC false \NC \NC \NR +\LL +\stoptabulate + +\stopchapter + +\stopcomponent + diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-axis.tex b/doc/context/sources/general/manuals/luametafun/luametafun-axis.tex new file mode 100644 index 000000000..f9483039c --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-axis.tex @@ -0,0 +1,83 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-axis + +\startchapter[title={Axis}] + +The axis macro is the result of one of the first experiments with the key|/|value +interface in \METAFUN. Let's show a lot in one example: + +\startbuffer[1] +\startMPcode + draw lmt_axis [ + sx = 5mm, sy = 5mm, + nx = 20, ny = 10, + dx = 5, dy = 2, + tx = 10, ty = 10, + + list = { + [ + connect = true, + color = "darkred", + close = true, + points = { (1, 1), (15, 8), (2, 10) }, + texts = { "segment 1", "segment 2", "segment 3" } + ], + [ + connect = true, + color = "darkgreen", + points = { (2, 2), (4, 1), (10, 3), (16, 8), (19, 2) }, + labels = { "a", "b", "c", "d", "e" } + ], + [ + connect = true, + color = "darkblue", + close = true, + points = { (5, 3), (8, 8), (16, 1) }, + labels = { "1", "2", "3" } + ] + }, + + ] withpen pencircle scaled 1mm ; +\stopMPcode +\stopbuffer + +\typebuffer[1][option=TEX] + +\startplacefigure[reference=axis:1] + \getbuffer[1] +\stopplacefigure + +This macro will probably be extended at some point. + +\starttabulate[|T|T|T|p|] +\FL +\BC name \BC type \BC default \BC comment \NC \NR +\ML +\NC nx \NC numeric \NC 1 \NC \NC \NR +\NC dx \NC numeric \NC 1 \NC \NC \NR +\NC tx \NC numeric \NC 0 \NC \NC \NR +\NC sx \NC numeric \NC 1 \NC \NC \NR +\NC startx \NC numeric \NC 0 \NC \NC \NR +\NC ny \NC numeric \NC 1 \NC \NC \NR +\NC dy \NC numeric \NC 1 \NC \NC \NR +\NC ty \NC numeric \NC 0 \NC \NC \NR +\NC sy \NC numeric \NC 1 \NC \NC \NR +\NC starty \NC numeric \NC 0 \NC \NC \NR +\ML \NC \NC \NR +\NC samples \NC list \NC \NC \NC \NR +\NC list \NC list \NC \NC \NC \NR +\NC connect \NC boolean \NC false \NC \NC \NR +\NC list \NC list \NC \NC \NC \NR +\NC close \NC boolean \NC false \NC \NC \NR +\NC samplecolors \NC list \NC \NC \NC \NR +\NC axiscolor \NC string \NC \NC \NC \NR +\NC textcolor \NC string \NC \NC \NC \NR +\LL +\stoptabulate + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-chart.tex b/doc/context/sources/general/manuals/luametafun/luametafun-chart.tex new file mode 100644 index 000000000..1bd89d350 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-chart.tex @@ -0,0 +1,441 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-chart + +\startchapter[title={Chart}] + +This is another example implementation but it might be handy for simple cases of +presenting results. Of course one can debate the usefulness of certain ways of +presenting but here we avoid that discussion. Let's start with a simple pie +chart (\in {figure} [chart:1]). + +\startbuffer[1] +\startMPcode + draw lmt_chart_circle [ + samples = { { 1, 4, 3, 2, 5, 7, 6 } }, + percentage = true, + trace = true, + ] ; +\stopMPcode +\stopbuffer + +\typebuffer[1][option=TEX] + +\startplacefigure[reference=chart:1] + \getbuffer[1] +\stopplacefigure + +As with all these \LMTX\ extensions, you're invited to play with the parameters. +in \in {figure} [chart:2] we see a variant that adds labels as well as one that +has a legend. + +\startbuffer[2a] +\startMPcode +draw lmt_chart_circle [ + height = 4cm, + samples = { { 1, 4, 3, 2, 5, 7, 6 } }, + percentage = true, + trace = true, + labelcolor = "white", + labelformat = "@0.1f", + labelstyle = "ttxx" +] ; +\stopMPcode +\stopbuffer + +The styling of labels and legends can be influenced independently. + +\typebuffer[2a][option=TEX] + +\startbuffer[2b] +\startMPcode +draw lmt_chart_circle [ + height = 4cm, + samples = { { 1, 4, 3, 2, 5, 7, 6 } }, + percentage = false, + trace = true, + linewidth = .125mm, + originsize = 0, + labeloffset = 3cm, + labelstyle = "bfxx", + legendstyle = "tfxx", + legend = { + "first", "second", "third", "fourth", + "fifth", "sixths", "sevenths" + } +] ; + +\stopMPcode +\stopbuffer + +\typebuffer[2b][option=TEX] + +\startplacefigure[reference=chart:2] + \startcombination + {\getbuffer[2a]} {} + {\getbuffer[2b]} {} + \stopcombination +\stopplacefigure + +A second way of rendering are histograms, and the interface is mostly the same. +In \in {figure} [chart:3] we see two variants + +\startbuffer[3a] +\startMPcode + draw lmt_chart_histogram [ + samples = { { 1, 4, 3, 2, 5, 7, 6 } }, + percentage = true, + cumulative = true, + trace = true, + ] ; +\stopMPcode +\stopbuffer + +\startbuffer[3b] +\startMPcode + draw lmt_chart_histogram [ + samples = { + { 1, 4, 3, 2, 5, 7, 6 }, + { 1, 2, 3, 4, 5, 6, 7 } + }, + background = "lightgray", + trace = true, + ] ; +\stopMPcode +\stopbuffer + +\typebuffer[3a][option=TEX] + +and one with two datasets: + +\typebuffer[3b][option=TEX] + +\startplacefigure[reference=chart:3] + \startcombination + {\getbuffer[3a]} {} + {\getbuffer[3b]} {} + \stopcombination +\stopplacefigure + +\startbuffer[4] +\startMPpage[offset=5mm] + draw lmt_chart_histogram [ + samples = { + { 1, 4, 3, 2, 5, 7, 6 }, + { 1, 2, 3, 4, 5, 6, 7 } + }, + percentage = true, + cumulative = true, + showlabels = false, + backgroundcolor = "lightgray", + ] ; +\stopMPpage +\stopbuffer + +A cumulative variant is shown in \in {figure} [chart:4] where we also add a +background (color). + +\typebuffer[4][option=TEX] + +\startplacefigure[reference=chart:4] + \getbuffer[4] +\stopplacefigure + +A different way of using colors is shown in \in {figure} [chart:5] where each +sample gets its own (same) color. + +\startbuffer[5] +\startMPcode + draw lmt_chart_histogram [ + samples = { + { 1, 4, 3, 2, 5, 7, 6 }, + { 1, 2, 3, 4, 5, 6, 7 } + }, + percentage = true, + cumulative = true, + showlabels = false, + background = "lightgray", + colormode = "local", + ] ; +\stopMPcode +\stopbuffer + +\typebuffer[5][option=TEX] + +\startplacefigure[reference=chart:5] + \getbuffer[5] +\stopplacefigure + +As with pie charts you can add labels and a legend: + +\startbuffer[6a] +\startMPcode + draw lmt_chart_histogram [ + height = 6cm, + samples = { { 1, 4, 3, 2, 5, 7, 6 } }, + percentage = true, + cumulative = true, + trace = true, + labelstyle = "ttxx", + labelanchor = "top", + labelcolor = "white", + backgroundcolor = "middlegray", + ] ; +\stopMPcode +\stopbuffer + +\typebuffer[6a][option=TEX] + +The previous and next examples are shown in \in {figure} [chart:6]. The height +specified here concerns the graphic and excludes the labels, + +\startbuffer[6b] +\startMPcode + draw lmt_chart_histogram [ + height = 6cm, + width = 10mm, + samples = { { 1, 4, 3, 2, 5, 7, 6 } }, + trace = true, + maximum = 7.5, + linewidth = 1mm, + originsize = 0, + labelanchor = "bot", + labelcolor = "black" + labelstyle = "bfxx" + legendstyle = "tfxx", + labelstrut = "yes", + legend = { + "first", "second", "third", "fourth", + "fifth", "sixths", "sevenths" + } + ] ; +\stopMPcode +\stopbuffer + +\typebuffer[6b][option=TEX] + +\startplacefigure[reference=chart:6] + \startcombination + {\getbuffer[6a]} {} + {\getbuffer[6b]} {} + \stopcombination +\stopplacefigure + +The third category concerns bar charts that run horizontal. Again we see similar +options driving the rendering (\in {figure} [chart:7]). + +\startbuffer[7a] +\startMPcode + draw lmt_chart_bar [ + samples = { { 1, 4, 3, 2, 5, 7, 6 } }, + percentage = true, + cumulative = true, + trace = true, + ] ; +\stopMPcode +\stopbuffer + +\typebuffer[7a][option=TEX] + +\startbuffer[7b] +\startMPcode + draw lmt_chart_bar [ + samples = { { 1, 4, 3, 2, 5, 7, 6 } }, + percentage = true, + cumulative = true, + showlabels = false, + backgroundcolor = "lightgray", + ] ; +\stopMPcode +\stopbuffer + +\typebuffer[7b][option=TEX] + +Determining the offset of labels is manual work: + +\startbuffer[7c] +\startMPcode +draw lmt_chart_bar [ + width = 4cm, + height = 5mm, + samples = { { 1, 4, 3, 2, 5, 7, 6 } }, + percentage = true, + cumulative = true, + trace = true, + labelcolor = "white", + labelstyle = "ttxx", + labelanchor = "rt", + labeloffset = .25EmWidth, + backgroundcolor = "middlegray", +] ; +\stopMPcode +\stopbuffer + +\typebuffer[7c][option=TEX] + +\startplacefigure[reference=chart:7] + \startcombination[3*1] + {\getbuffer[7a]} {} + {\getbuffer[7b]} {} + {\getbuffer[7c]} {} + \stopcombination +\stopplacefigure + +Here is one with a legend (rendered in \in {figure} [chart:8]): + +\startbuffer[8] +\startMPcode +draw lmt_chart_bar [ + width = 8cm, + height = 10mm, + samples = { { 1, 4, 3, 2, 5, 7, 6 } }, + trace = true, + maximum = 7.5, + linewidth = 1mm, + originsize = 0, + labelanchor = "lft", + labelcolor = "black" + labelstyle = "bfxx" + legendstyle = "tfxx", + labelstrut = "yes", + legend = { + "first", "second", "third", "fourth", + "fifth", "sixths", "sevenths" + } +] ; +\stopMPcode +\stopbuffer + +\typebuffer[8][option=TEX] + +\startplacefigure[reference=chart:8] + \getbuffer[8] +\stopplacefigure + +You can have labels per dataset as well as draw multiple datasets in +one image, see \in {figure} [chart:9]: + +\startbuffer[9] +\startMPcode + draw lmt_chart_bar [ + samples = { + { 1, 4, 3, 2, 5, 7, 6 }, + { 3, 2, 5, 7, 5, 6, 1 } + }, + labels = { + { "a1", "b1", "c1", "d1", "e1", "f1", "g1" }, + { "a2", "b2", "c2", "d2", "e2", "f2", "g2" } + }, + labeloffset = -EmWidth, + labelanchor = "center", + labelstyle = "ttxx", + trace = true, + center = true, + ] ; + + draw lmt_chart_bar [ + samples = { + { 1, 4, 3, 2, 5, 7, 6 } + }, + labels = { + { "a", "b", "c", "d", "e", "f", "g" } + }, + labeloffset = -EmWidth, + labelanchor = "center", + trace = true, + center = true, + ] shifted (10cm,0) ; +\stopMPcode +\stopbuffer + +\typebuffer[9][option=TEX] + +\startplacefigure[reference=chart:9] + \getbuffer[9] +\stopplacefigure + +\starttabulate[|T|T|T|p|] +\FL +\BC name \BC type \BC default \BC comment \NC \NR +\ML +\NC originsize \NC numeric \NC 1mm \NC \NC \NR +\NC trace \NC boolean \NC false \NC \NC \NR +\NC showlabels \NC boolean \NC true \NC \NC \NR +\NC center \NC boolean \NC false \NC \NC \NR +\ML +\NC samples \NC list \NC \NC \NC \NR +\NC +\NC cumulative \NC boolean \NC false \NC \NC \NR +\NC percentage \NC boolean \NC false \NC \NC \NR +\NC maximum \NC numeric \NC 0 \NC \NC \NR +\NC distance \NC numeric \NC 1mm \NC \NC \NR +\ML +\NC labels \NC list \NC \NC \NC \NR +\NC labelstyle \NC string \NC \NC \NC \NR +\NC labelformat \NC string \NC \NC \NC \NR +\NC labelstrut \NC string \NC auto \NC \NC \NR +\NC labelanchor \NC string \NC \NC \NC \NR +\NC labeloffset \NC numeric \NC 0 \NC \NC \NR +\NC labelfraction \NC numeric \NC 0.8 \NC \NC \NR +\NC labelcolor \NC string \NC \NC \NC \NR +\ML +\NC backgroundcolor \NC string \NC \NC \NC \NR +\NC drawcolor \NC string \NC white \NC \NC \NR +\NC fillcolors \NC list \NC \NC primary (dark) colors \NC \NR +\NC colormode \NC string \NC global \NC \NC or \type {local} \NC \NR +\ML +\NC linewidth \NC numeric \NC .25mm \NC \NC \NR +\ML +\NC legendcolor \NC string \NC \NC \NC \NR +\NC legendstyle \NC string \NC \NC \NC \NR +\NC legend \NC list \NC \NC \NC \NR +\LL +\stoptabulate + +Pie charts have: + +\starttabulate[|T|T|] +\FL +\BC name \BC default \NC \NR +\ML +\NC height \NC 5cm \NC \NR +\NC width \NC 5mm \NC \NR +\NC labelanchor \NC \NC \NR +\NC labeloffset \NC 0 \NC \NR +\NC labelstrut \NC no \NC \NR +\LL +\stoptabulate + +Histograms come with: + +\starttabulate[|T|T|] +\FL +\BC name \BC default \NC \NR +\ML +\NC height \NC 5cm \NC \NR +\NC width \NC 5mm \NC \NR +\NC labelanchor \NC bot \NC \NR +\NC labeloffset \NC 1mm \NC \NR +\NC labelstrut \NC auto \NC \NR +\LL +\stoptabulate + +Bar charts use: + +\starttabulate[|T|T|] +\FL +\BC name \BC default \NC \NR +\ML +\NC height \NC 5cm \NC \NR +\NC width \NC 5mm \NC \NR +\NC labelanchor \NC lft \NC \NR +\NC labeloffset \NC 1mm \NC \NR +\NC labelstrut \NC no \NC \NR +\LL +\stoptabulate + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-contents.tex b/doc/context/sources/general/manuals/luametafun/luametafun-contents.tex new file mode 100644 index 000000000..73800ba8b --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-contents.tex @@ -0,0 +1,11 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-contents + +\starttitle[title={Contents}] + \placelist[chapter] +\stoptitle + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-contour.tex b/doc/context/sources/general/manuals/luametafun/luametafun-contour.tex new file mode 100644 index 000000000..11eca8b7a --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-contour.tex @@ -0,0 +1,771 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-contour + +\startchapter[title={Contour}] + +This feature started out as experiment triggered by a request on the mailing +list. In the end it was a nice exploration of what is possible with a bit of +\LUA. In a sense it is more subsystem than a simple \METAPOST\ macro because +quite some \LUA\ code is involved and more might be used in the future. It's part +of the fun. + +A contour is a line through equivalent values $z$ that result from applying a +function to two variables $x$ and $y$. There is quite a bit of analysis needed +to get these lines. In \METAFUN\ we currently support three methods for generating +a colorful background and three for putting lines on top: + +One solution is to use the the isolines and isobands methods are described on the +marching squares page of wikipedia: + +\starttyping +https://en.wikipedia.org/wiki/Marching_squares +\stoptyping + +This method is relative efficient as we don't do much optimization, simply +because it takes time and the gain is not that much relevant. Because we support +filling of multiple curves in one go, we get efficient paths anyway without side +effects that normally can occur from many small paths alongside. In these days of +multi megabyte movies and sound clips a request of making a \PDF\ file small is kind +of strange anyway. In practice the penalty is not that large. + +As background we can use a bitmap. This method is also quite efficient because we +use indexed colors which results in a very good compression. We use a simple +mapping on a range of values. + +A third method is derived from the one that is distributed as \CCODE\ source +file at: + +\starttyping +https://physiology.arizona.edu/people/secomb/contours +https://github.com/secomb/GreensV4 +\stoptyping + +We can create a background image, which uses a sequence of closed curves +\footnote {I have to figure out how to improve it a bit so that multiple path +don't get connected.}. It can also provide two variants of lines around the +contours (we tag them shape and shade). It's all a matter of taste. In the +meantime I managed to optimize the code a bit and I suppose that when I buy a new +computer (the code was developed on an 8 year old machine) performance is +probably acceptable. + +In order of useability you can think of isoband (band) with isolines (cell), +bitmap (bitmap) with isolines (cell) and finally shapes (shape) with edges +(edge). But let's start with a couple of examples. + +\startbuffer[1] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = 0, xmax = 4*pi, xstep = .05, + ymin = -6, ymax = 6, ystep = .05, + + levels = 7, + height = 5cm, + preamble = "local sin, cos = math.sin, math.cos", + function = "cos(x) + sin(y)", + background = "bitmap", + foreground = "edge", + linewidth = 1/2, + cache = true, + ] ; +\stopMPcode +\stopbuffer + +\startplacefigure[reference=contour:1] + \getbuffer[1] +\stopplacefigure + +\typebuffer[1][option=TEX] + +In \in {figure} [contour:1] we see the result. There is a in this case black and +white image generated and on top of that we see lines. The step determines the +resolution of the image. In practice using a bitmap is quite okay and also rather +efficient: we use an indexed colorspace and, as already was mentioned, because +the number of colors is limited such an image compresses well. A different +rendering is seen in \in {figure} [contour:2] where we use the shape method for +the background. That method creates outlines but is much slower, and when you use +a high resolution (small step) it can take quite a while to identify the shapes. +This is why we set the cache flag. + +\startbuffer[2] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = 0, xmax = 4*pi, xstep = .10, + ymin = -6, ymax = 6, ystep = .10, + + levels = 7, + preamble = "local sin, cos = math.sin, math.cos", + function = "cos(x) - sin(y)", + background = "shape", + foreground = "shape", + linewidth = 1/2, + cache = true, + ] ; +\stopMPcode +\stopbuffer + +\typebuffer[2][option=TEX] + +\startplacefigure[reference=contour:2] + \getbuffer[2] +\stopplacefigure + +We mentioned colorspace but haven't seen any color yet, so let's set some in \in +{figure} [contour:3]. Two variants are shown: a background \type {shape} with +foreground \type {shape} and a background \type {bitmap} with a foreground \type +{edge}. The bitmap renders quite fast, definitely when we compare with the shape, +while the quality is as good at this size. + +\startbuffer[3a] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = -10, xmax = 10, xstep = .1, + ymin = -10, ymax = 10, ystep = .1, + + levels = 10, + height = 7cm, + color = "shade({1/2,1/2,0},{0,0,1/2})", + function = "x^2 + y^2", + background = "shape", + foreground = "shape", + linewidth = 1/2, + cache = true, + ] xsized .45TextWidth ; +\stopMPcode +\stopbuffer + +\startbuffer[3b] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = -10, xmax = 10, xstep = .1, + ymin = -10, ymax = 10, ystep = .1, + + levels = 10, + height = 7cm, + color = "shade({1/2,0,0},{0,0,1/2})", + function = "x^2 + y^2", + background = "bitmap", + foreground = "edge", + linewidth = 1/2, + cache = true, + ] xsized .45TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[3a][option=TEX] + +\startplacefigure[reference=contour:3] + \startcombination + {\getbuffer[3a]} {\bf shape} + {\getbuffer[3b]} {\bf bitmap} + \stopcombination +\stopplacefigure + +We use the \type {doublefun} instance because we need to be sure that we don't +run into issues with scaled numbers, the default model in \METAPOST. The +function that gets passed is {\em not} using \METAPOST\ but \LUA, so basically +you can do very complex things. Here we directly pass code, but you can for +instance also do this: + +\starttyping[option=TEX] +\startluacode + function document.MyContourA(x,y) + return x^2 + y^2 + end +\stopluacode +\stoptyping + +and then \type {function = "document.MyContourA(x,y)"}. As long as the function +returns a valid number we're okay. When you pass code directly you can use the +\type {preamble} key to set local shortcuts. In the previous examples we took +\type {sin} and \type {cos} from the math library but you can also roll out your +own functions and|/|or use the more elaborate \type {xmath} library. The color +parameter is also a function, one that returns one or three arguments. In the +next example we use \type {lin} to calculate a fraction of the current level and +total number of levels. + +\startbuffer[4a] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = -3, xmax = 3, xstep = .01, + ymin = -1, ymax = 1, ystep = .01, + + levels = 10, + default = .5, + height = 5cm, + function = "x^2 + y^2 + x + y/2", + color = "lin(l), 0, 1/2", + background = "bitmap" + foreground = "none", + cache = true, + ] xsized TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[4a][option=TEX] + +\startplacefigure[reference=contour:4a] + \getbuffer[4a] +\stopplacefigure + +Instead of a bitmap we can use an isoband, which boils down to a set of tiny +shapes that make up a bigger one. This is shown in \in {figure} [contour:4b]. + +\startbuffer[4b] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = -3, xmax = 3, xstep = .01, + ymin = -1, ymax = 1, ystep = .01, + + levels = 10, + default = .5, + height = 5cm, + function = "x^2 + y^2 + x + y/2", + color = "lin(l), 1/2, 0", + background = "band", + foreground = "none", + cache = true, + ] xsized TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[4b][option=TEX] + +\startplacefigure[reference=contour:4b] + \getbuffer[4b] +\stopplacefigure + +You can draw several functions and see where they overlap: + +\startbuffer[5] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = -pi, xmax = 4*pi, xstep = .1, + ymin = -3, ymax = 3, ystep = .1, + + range = { -.1, .1 }, + preamble = "local sin, cos = math.sin, math.cos", + functions = { + "sin(x) + sin(y)", "sin(x) + cos(y)", + "cos(x) + sin(y)", "cos(x) + cos(y)" + }, + background = "bitmap", + linecolor = "black", + linewidth = 1/10, + color = "shade({1,1,0},{0,0,1})" + cache = true, + ] xsized TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[5][option=TEX] + +\startplacefigure[reference=contour:5] + \getbuffer[5] +\stopplacefigure + +The range determines the $z$ value(s) that we take into account. You can also +pass a list of colors to be used. In \in {figure} [contour:6] this is +demonstrated. There we also show a variant foreground \type {cell}, which uses a +bit different method for calculating the edges. \footnote {This a bit of a +playground: more variants might show up in due time.} + +\startbuffer[6] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = -2*pi, xmax = 2*pi, xstep = .01, + ymin = -3, ymax = 3, ystep = .01, + + range = { -.1, .1 }, + preamble = "local sin, cos = math.sin, math.cos", + functions = { "sin(x) + sin(y)", "sin(x) + cos(y)" }, + background = "bitmap", + foreground = "cell", + linecolor = "white", + linewidth = 1/10, + colors = { (1/2,1/2,1/2), red, green, blue } + level = 3, + linewidth = 6, + cache = true, + ] xsized TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[6][option=TEX] + +Here the number of levels depends on the number of functions as each can overlap +with another; for instance the outcome of two functions can overlap or not which +means 3 cases, and with a value not being seen that gives 4 different cases. + +\startplacefigure[reference=contour:6] + \getbuffer[6] +\stopplacefigure + +\startbuffer[7] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = -2*pi, xmax = 2*pi, xstep = .01, + ymin = -3, ymax = 3, ystep = .01, + + range = { -.1, .1 }, + preamble = "local sin, cos = math.sin, math.cos", + functions = { + "sin(x) + sin(y)", + "sin(x) + cos(y)", + "cos(x) + sin(y)", + "cos(x) + cos(y)" + }, + background = "bitmap", + foreground = "none", + level = 3, + color = "shade({2/3,0,0},{2/3,1,2/3})" + cache = true, + ] xsized TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[7][option=TEX] + +Of course one can wonder how useful showing many functions but it can give nice +pictures, as shown in \in {figure} [contour:7]. + +\startplacefigure[reference=contour:7] + \getbuffer[7] +\stopplacefigure + +\startbuffer[8] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = -2*pi, xmax = 2*pi, xstep = .01, + ymin = -3, ymax = 3, ystep = .01, + + range = { -.3, .3 }, + preamble = "local sin, cos = math.sin, math.cos", + functions = { + "sin(x) + sin(y)", + "sin(x) + cos(y)", + "cos(x) + sin(y)", + "cos(x) + cos(y)" + }, + background = "bitmap", + foreground = "none", + level = 3, + color = "shade({1,0,0},{0,1,0})" + cache = true, + ] xsized TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[8][option=TEX] + +We can enlargen the window, which is demonstrated in \in {figure} [contour:8]. I +suppose that such images only make sense in educational settings. + +\startplacefigure[reference=contour:8] + \getbuffer[8] +\stopplacefigure + +% \startbuffer[9a] +% \startMPcode{doublefun} +% draw lmt_contour [ +% xmin = -10, xmax = 10, xstep = 1, +% ymin = -10, ymax = 10, ystep = 1, +% function = "math.random(1,3)", levels = 3, +% linecolor = "white", linewidth = 1/10, +% width = .3TextWidth, legend = "none", +% color = "shade({1/2,1/2,0},{0,0,1})" +% +% background = "bitmap", foreground = "edge", +% ] ; +% \stopMPcode +% \stopbuffer +% +% \typebuffer[9a][option=TEX] +% +% \startbuffer[9b] +% \startMPcode{doublefun} +% draw lmt_contour [ +% xmin = -10, xmax = 10, xstep = 1, +% ymin = -10, ymax = 10, ystep = 1, +% function = "math.random(1,3)", levels = 3, +% linecolor = "white", linewidth = 1/10, +% width = .3TextWidth, legend = "none", +% color = "shade({1/2,1/2,0},{0,0,1/2})" +% +% background = "bitmap", foreground = "cell", +% ] ; +% \stopMPcode +% \stopbuffer +% +% \startbuffer[9c] +% \startMPcode{doublefun} +% draw lmt_contour [ +% xmin = -10, xmax = 10, xstep = 1, +% ymin = -10, ymax = 10, ystep = 1, +% function = "math.random(1,3)", levels = 3, +% linecolor = "white", linewidth = 1/10, +% width = .3TextWidth, legend = "none", +% color = "shade({1/2,1/2,0},{0,0,1})" +% +% background = "bitmap", foreground = "none", +% ] ; +% \stopMPcode +% \stopbuffer +% +% \startbuffer[9d] +% \startMPcode{doublefun} +% draw lmt_contour [ +% xmin = -10, xmax = 10, xstep = 1, +% ymin = -10, ymax = 10, ystep = 1, +% function = "math.random(1,3)", levels = 3, +% linecolor = "white", linewidth = 1/10, +% width = .3TextWidth, legend = "none", +% color = "shade({1/2,1/2,0},{0,0,1})" +% +% background = "shape", foreground = "shape", +% ] ; +% \stopMPcode +% \stopbuffer +% +% \startbuffer[9e] +% \startMPcode{doublefun} +% draw lmt_contour [ +% xmin = -10, xmax = 10, xstep = 1, +% ymin = -10, ymax = 10, ystep = 1, +% function = "math.random(1,3)", levels = 3, +% linecolor = "white", linewidth = 1/10, +% width = .3TextWidth, legend = "none", +% color = "shade({1/2,1/2,0},{0,0,1})" +% +% background = "shape", foreground = "edge", +% ] ; +% \stopMPcode +% \stopbuffer +% +% \startbuffer[9f] +% \startMPcode{doublefun} +% draw lmt_contour [ +% xmin = -10, xmax = 10, xstep = 1, +% ymin = -10, ymax = 10, ystep = 1, +% function = "math.random(1,3)", levels = 3, +% linecolor = "white", linewidth = 1/10, +% width = .3TextWidth, legend = "none", +% color = "shade({1/2,1/2,0},{0,0,1})" +% +% background = "shape", foreground = "none", +% ] ; +% \stopMPcode +% \stopbuffer +% +% \startbuffer[9g] +% \startMPcode{doublefun} +% draw lmt_contour [ +% xmin = -10, xmax = 10, xstep = 1, +% ymin = -10, ymax = 10, ystep = 1, +% function = "math.random(1,3)", levels = 3, +% linecolor = "white", linewidth = 1/10, +% width = .3TextWidth, legend = "none", +% color = "shade({1/2,1/2,0},{0,0,1})" +% +% background = "band", foreground = "edge", +% ] ; +% \stopMPcode +% \stopbuffer +% +% \startbuffer[9h] +% \startMPcode{doublefun} +% draw lmt_contour [ +% xmin = -10, xmax = 10, xstep = 1, +% ymin = -10, ymax = 10, ystep = 1, +% function = "math.random(1,3)", levels = 3, +% linecolor = "white", linewidth = 1/10, +% width = .3TextWidth, legend = "none", +% color = "shade({1/2,1/2,0},{0,0,1})" +% +% background = "band", foreground = "cell", +% ] ; +% \stopMPcode +% \stopbuffer +% +% \startbuffer[9i] +% \startMPcode{doublefun} +% draw lmt_contour [ +% xmin = -10, xmax = 10, xstep = 1, +% ymin = -10, ymax = 10, ystep = 1, +% function = "math.random(1,3)", levels = 3, +% linecolor = "white", linewidth = 1/10, +% width = .3TextWidth, legend = "none", +% color = "shade({1/2,1/2,0},{0,0,1})" +% +% background = "band", foreground = "none", +% ] ; +% \stopMPcode +% \stopbuffer +% +% In \in {figure} [contour:9] we see that using the shape option doesn't work out +% too well here, which again demonstrates that using the bitmap method is not that +% bad. In that example we use random numbers, just to show the erratic behavior. In +% \in {figure} [contour:10] a more sane image is used. The band and bitmap examples +% are generated quite fast so no caching is used there. We only show one definition: +% +% \typebuffer[9i][option=TEX] +% +% \startplacefigure[reference=contour:9] +% \startcombination[3*3] +% {\pushrandomseed\setrandomseed{1}\getbuffer[9a]\poprandomseed} {\bf bitmap edge} +% {\pushrandomseed\setrandomseed{1}\getbuffer[9b]\poprandomseed} {\bf bitmap cell} +% {\pushrandomseed\setrandomseed{1}\getbuffer[9c]\poprandomseed} {\bf bitmap none} +% {\pushrandomseed\setrandomseed{1}\getbuffer[9d]\poprandomseed} {\bf shape shape} +% {\pushrandomseed\setrandomseed{1}\getbuffer[9e]\poprandomseed} {\bf shape edge} +% {\pushrandomseed\setrandomseed{1}\getbuffer[9f]\poprandomseed} {\bf shape none} +% {\pushrandomseed\setrandomseed{1}\getbuffer[9g]\poprandomseed} {\bf band edge} +% {\pushrandomseed\setrandomseed{1}\getbuffer[9h]\poprandomseed} {\bf band cell} +% {\pushrandomseed\setrandomseed{1}\getbuffer[9i]\poprandomseed} {\bf band none} +% \stopcombination +% \stopplacefigure + +In \in {figure} [contour:10] we see different combinations of backgrounds (in color) +and foregrounds (edges) in action. + +\startbuffer[10a] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = 0, xmax = 4*pi, xstep = 0, + ymin = -6, ymax = 6, ystep = 0, + + levels = 5, legend = false, linewidth = 1/2, + + preamble = "local sin, cos = math.sin, math.cos", + function = "cos(x) - sin(y)", + color = "shade({1/2,0,0},{0,0,1/2})", + + background = "bitmap", foreground = "edge", + ] xsized .3TextWidth ; +\stopMPcode +\stopbuffer + +\startbuffer[10b] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = 0, xmax = 4*pi, xstep = 0, + ymin = -6, ymax = 6, ystep = 0, + + levels = 5, legend = false, linewidth = 1/2, + + preamble = "local sin, cos = math.sin, math.cos", + function = "cos(x) - sin(y)", + color = "shade({1/2,0,0},{0,0,1/2})", + + background = "bitmap", foreground = "cell", + ] xsized .3TextWidth ; +\stopMPcode +\stopbuffer + +\startbuffer[10c] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = 0, xmax = 4*pi, xstep = 0, + ymin = -6, ymax = 6, ystep = 0, + + levels = 5, legend = false, linewidth = 1/2, + + preamble = "local sin, cos = math.sin, math.cos", + function = "cos(x) - sin(y)", + color = "shade({1/2,0,0},{0,0,1/2})", + + background = "bitmap", foreground = "none", + ] xsized .3TextWidth ; +\stopMPcode +\stopbuffer + +\startbuffer[10d] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = 0, xmax = 4*pi, xstep = 0, + ymin = -6, ymax = 6, ystep = 0, + + levels = 5, legend = false, linewidth = 1/2, + + preamble = "local sin, cos = math.sin, math.cos", + function = "cos(x) - sin(y)", + color = "shade({1/2,0,0},{0,0,1/2})", + + background = "shape", foreground = "shape", cache = true, + ] xsized .3TextWidth ; +\stopMPcode +\stopbuffer + +\startbuffer[10e] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = 0, xmax = 4*pi, xstep = 0, + ymin = -6, ymax = 6, ystep = 0, + + levels = 5, legend = false, linewidth = 1/2, + + preamble = "local sin, cos = math.sin, math.cos", + function = "cos(x) - sin(y)", + color = "shade({1/2,0,0},{0,0,1/2})", + + background = "shape", foreground = "edge", cache = true, + ] xsized .3TextWidth ; +\stopMPcode +\stopbuffer + +\startbuffer[10f] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = 0, xmax = 4*pi, xstep = 0, + ymin = -6, ymax = 6, ystep = 0, + + levels = 5, legend = false, linewidth = 1/2, + + preamble = "local sin, cos = math.sin, math.cos", + function = "cos(x) - sin(y)", + color = "shade({1/2,0,0},{0,0,1/2})", + + background = "shape", foreground = "none", cache = true, + ] xsized .3TextWidth ; +\stopMPcode +\stopbuffer + +\startbuffer[10g] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = 0, xmax = 4*pi, xstep = 0, + ymin = -6, ymax = 6, ystep = 0, + + levels = 5, legend = false, linewidth = 1/2, + + preamble = "local sin, cos = math.sin, math.cos", + function = "cos(x) - sin(y)", + color = "shade({1/2,0,0},{0,0,1/2})", + + background = "band", foreground = "edge", + ] xsized .3TextWidth ; +\stopMPcode +\stopbuffer + +\startbuffer[10h] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = 0, xmax = 4*pi, xstep = 0, + ymin = -6, ymax = 6, ystep = 0, + + levels = 5, legend = false, linewidth = 1/2, + + preamble = "local sin, cos = math.sin, math.cos", + function = "cos(x) - sin(y)", + color = "shade({1/2,0,0},{0,0,1/2})", + + background = "band", foreground = "cell", + ] xsized .3TextWidth ; +\stopMPcode +\stopbuffer + +\startbuffer[10i] +\startMPcode{doublefun} + draw lmt_contour [ + xmin = 0, xmax = 4*pi, xstep = 0, + ymin = -6, ymax = 6, ystep = 0, + + levels = 5, legend = false, linewidth = 1/2, + + preamble = "local sin, cos = math.sin, math.cos", + function = "cos(x) - sin(y)", + color = "shade({1/2,0,0},{0,0,1/2})", + + background = "band", foreground = "none", + ] xsized .3TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[10b][option=TEX] + +% \page + +There are quite some settings. Some deal with the background, some with the +foreground and quite some deal with the legend. + +\starttabulate[|T|T|T|p|] +\FL +\BC name \BC type \BC default \BC comment \NC \NR +\ML +\NC xmin \NC numeric \NC 0 \NC needs to be set \NC \NR +\NC xmax \NC numeric \NC 0 \NC needs to be set \NC \NR +\NC ymin \NC numeric \NC 0 \NC needs to be set \NC \NR +\NC ymax \NC numeric \NC 0 \NC needs to be set \NC \NR +\NC xstep \NC numeric \NC 0 \NC auto 1/200 when zero \NC \NR +\NC ystep \NC numeric \NC 0 \NC auto 1/200 when zero \NC \NR +\NC checkresult \NC boolean \NC false \NC checks for overflow and NaN \NC \NR +\NC defaultnan \NC numeric \NC 0 \NC the value to be used when NaN \NC \NR +\NC defaultinf \NC numeric \NC 0 \NC the value to be used when overflow \NC \NR +\ML +\NC levels \NC numeric \NC 10 \NC number of different levels to show \NC \NR +\NC level \NC numeric \NC \NC only show this level (foreground) \NC \NR +\ML +\NC preamble \NC string \NC \NC shortcuts \NC \NR +\NC function \NC string \NC x + y \NC the result z value \NC \NR +\NC functions \NC list \NC \NC multiple functions (overlapping levels) \NC \NR +\NC color \NC string \NC lin(l) \NC the result color value for level l (1 or 3 values) \NC \NR +\NC colors \NC numeric \NC \NC used when set \NC \NR +\ML +\NC background \NC string \NC bitmap \NC band, bitmap, shape \NC \NR +\NC foreground \NC string \NC auto \NC cell, edge, shape auto \NC \NR +\ML +\NC linewidth \NC numeric \NC .25 \NC \NC \NR +%NC backgroundcolor \NC string \NC black \NC \NC \NR +\NC linecolor \NC string \NC gray \NC \NC \NR +\ML +\NC width \NC numeric \NC 0 \NC automatic when zero \NC \NR +\NC height \NC numeric \NC 0 \NC automatic when zero \NC \NR +\ML +\NC trace \NC boolean \NC false \NC \NC \NR +\ML +\NC legend \NC string \NC all \NC x y z function range all \NC \NR +\NC legendheight \NC numeric \NC LineHeight \NC \NC \NR +\NC legendwidth \NC numeric \NC LineHeight \NC \NC \NR +\NC legendgap \NC numeric \NC 0 \NC \NC \NR +\NC legenddistance \NC numeric \NC EmWidth \NC \NC \NR +\NC textdistance \NC numeric \NC 2EmWidth/3 \NC \NC \NR +\NC functiondistance \NC numeric \NC ExHeight \NC \NC \NR +\NC functionstyle \NC string \NC \NC \CONTEXT\ style name \NC \NR +\NC xformat \NC string \NC @0.2N \NC number format template \NC \NR +\NC yformat \NC string \NC @0.2N \NC number format template \NC \NR +\NC zformat \NC string \NC @0.2N \NC number format template \NC \NR +\NC xstyle \NC string \NC \NC \CONTEXT\ style name \NC \NR +\NC ystyle \NC string \NC \NC \CONTEXT\ style name \NC \NR +\NC zstyle \NC string \NC \NC \CONTEXT\ style name \NC \NR +\ML +\NC axisdistance \NC numeric \NC ExHeight \NC \NC \NR +\NC axislinewidth \NC numeric \NC .25 \NC \NC \NR +\NC axisoffset \NC numeric \NC ExHeight/4 \NC \NC \NR +\NC axiscolor \NC string \NC black \NC \NC \NR +\NC ticklength \NC numeric \NC ExHeight \NC \NC \NR +\ML +\NC xtick \NC numeric \NC 5 \NC \NC \NR +\NC ytick \NC numeric \NC 5 \NC \NC \NR +\NC xlabel \NC numeric \NC 5 \NC \NC \NR +\NC ylabel \NC numeric \NC 5 \NC \NC \NR +\LL +\stoptabulate + +\startplacefigure[reference=contour:10] + \startcombination[3*3] + {\getbuffer[10a]} {\bf bitmap edge} + {\getbuffer[10b]} {\bf bitmap cell} + {\getbuffer[10c]} {\bf bitmap none} + {\getbuffer[10d]} {\bf shape shape} + {\getbuffer[10e]} {\bf shape edge} + {\getbuffer[10f]} {\bf shape none} + {\getbuffer[10g]} {\bf band edge} + {\getbuffer[10h]} {\bf band cell} + {\getbuffer[10i]} {\bf band none} + \stopcombination +\stopplacefigure + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-followtext.tex b/doc/context/sources/general/manuals/luametafun/luametafun-followtext.tex new file mode 100644 index 000000000..079131565 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-followtext.tex @@ -0,0 +1,124 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-followtext + +\startchapter[title={Followtext}] + +Typesetting text along a path started as a demo if communication between \TEX\ and +\METAPOST\ in the early days of \METAFUN. In the meantime the implementation has +been modernized a few times and the current implementation feels okay, especially +now that we have a better user interface. Here is an example: + +\startbuffer[1a] +\startMPcode{doublefun} + draw lmt_followtext [ + text = "How well does it work {\bf 1}! ", + path = fullcircle scaled 4cm, + trace = true, + spread = true, + ] ysized 5cm ; +\stopMPcode +\stopbuffer + +\typebuffer[1a][option=TEX] + +Here is the same example but with the text in the reverse order. The results of both examples +are shown in \in {figure} [followtext:1]. + +\startbuffer[1b] +\startMPcode{doublefun} + draw lmt_followtext [ + text = "How well does it work {\bf 2}! ", + path = fullcircle scaled 4cm, + trace = true, + spread = false, + reverse = true, + ] ysized 5cm ; +\stopMPcode +\stopbuffer + +\typebuffer[1b][option=TEX] + +\startplacefigure[reference=followtext:1] + \startcombination[2*2] + {\getbuffer[1a]} {} + {\getbuffer[1b]} {} + \stopcombination +\stopplacefigure + +There are not that many options. One is \type {autoscale} which makes the shape +and text match. \in {Figure} [followtext:2] shows what happens. + +\startbuffer[2a] +\startMPcode{doublefun} + draw lmt_followtext [ + text = "How well does it work {\bf 3}! ", + trace = true, + autoscaleup = "yes" + ] ysized 5cm ; +\stopMPcode +\stopbuffer + +\typebuffer[2a][option=TEX] + +\startbuffer[2b] +\startMPcode{doublefun} + draw lmt_followtext [ + text = "How well does it work {\bf 4}! ", + path = fullcircle scaled 2cm, + trace = true, + autoscaleup = "max" + ] ysized 5cm ; +\stopMPcode +\stopbuffer + +\typebuffer[2b][option=TEX] + +\startplacefigure[reference=followtext:2] + \startcombination[2*2] + {\getbuffer[2a]} {} + {\getbuffer[2b]} {} + \stopcombination +\stopplacefigure + +You can use quite strange paths, like the one show in \in {figure} +[followtext:3]. Watch the parenthesis around the path. this is really needed in +order for the scanner to pick up the path (otherwise it sees a pair). + +\startbuffer[3] +\startMPcode{doublefun} + draw lmt_followtext [ + text = "\samplefile {zapf}", + path = ((3,0) .. (1,0) .. (5,0) .. (2,0) .. (4,0) .. (3,0)), + autoscaleup = "max" + ] xsized TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[3][option=TEX] + +\startplacefigure[reference=followtext:3] + \getbuffer[3] +\stopplacefigure + +The small set of options is: + +\starttabulate[|T|T|T|p|] +\FL +\BC name \BC type \BC default \BC comment \NC \NR +\ML +\NC text \NC string \NC \NC \NC \NR +\NC spread \NC string \NC true \NC \NC \NR +\NC trace \NC numeric \NC false \NC \NC \NR +\NC reverse \NC numeric \NC false \NC \NC \NR +\NC autoscaleup \NC numeric \NC no \NC \NC \NR +\NC autoscaledown \NC string \NC no \NC \NC \NR +\NC path \NC string \NC (fullcircle) \NC \NC \NR +\LL +\stoptabulate + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-function.tex b/doc/context/sources/general/manuals/luametafun/luametafun-function.tex new file mode 100644 index 000000000..79fa97a21 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-function.tex @@ -0,0 +1,296 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-function + +\startchapter[title={Function}] + +It is tempting to make helpers that can do a lot. However, that also means that +we need to explain a lot. Instead it makes more sense to have specific helpers +and just make another one when needed. Rendering functions falls into this +category. At some point users will come up with specific cases that other users +can use. Therefore, the solution presented here is not the ultimate answer. We +start with a simple example: + +\startbuffer[1] +\startMPcode{doublefun} + draw lmt_function [ + xmin = 0, xmax = 20, xstep = .1, + ymin = -2, ymax = 2, + + sx = 1mm, xsmall = 80, xlarge = 20, + sy = 4mm, ysmall = 40, ylarge = 4, + + linewidth = .025mm, offset = .1mm, + + code = "1.5 * math.sind (50 * x - 150)", + ] + xsized 8cm + ; +\stopMPcode +\stopbuffer + +\startplacefigure + \getbuffer[1] +\stopplacefigure + +This image is defined as follows: + +\typebuffer[1][option=TEX] + +\startbuffer[2] +\startMPcode{doublefun} + draw lmt_function [ + xmin = 0, xmax = 20, xstep = .1, + ymin = -2, ymax = 2, + + sx = 1mm, xsmall = 80, xlarge = 20, + sy = 4mm, ysmall = 40, ylarge = 4, + + linewidth = .025mm, offset = .1mm, + + xticks = "bottom", + yticks = "left", + xlabels = "nolimits", + ylabels = "yes", + code = "1.5 * math.sind (50 * x - 150)", + % frame = "ticks", + frame = "sticks", + ycaption = "\strut \rotate[rotation=90]{something vertical, using $\sin{x}$}", + xcaption = "\strut something horizontal", + functions = { + [ xmin = 1.0, xmax = 7.0, close = true, fillcolor = "darkred" ], + [ xmin = 7.0, xmax = 12.0, close = true, fillcolor = "darkgreen" ], + [ xmin = 12.0, xmax = 19.0, close = true, fillcolor = "darkblue" ], + [ + drawcolor = "darkyellow", + drawsize = 2 + ] + } + ] + xsized TextWidth + ; +\stopMPcode +\stopbuffer + +We can draw multiple functions in one go. The next sample split the drawing over +a few ranges and is defined as follows; in \in {figure} [function:2] we see the +result. + +\typebuffer[2][option=TEX] + + +\startplacefigure[reference=function:2] + \getbuffer[2] +\stopplacefigure + +Instead of the same function, we can draw different ones and when we use transparency +we get nice results too. + +\startbuffer[3] +\definecolor[MyColorR][r=.5,t=.5,a=1] +\definecolor[MyColorG][g=.5,t=.5,a=1] +\definecolor[MyColorB][b=.5,t=.5,a=1] + +\startMPcode{doublefun} + draw lmt_function [ + xmin = 0, xmax = 20, xstep = .1, + ymin = -1, ymax = 1, + + sx = 1mm, xsmall = 80, xlarge = 20, + sy = 4mm, ysmall = 40, ylarge = 4, + + linewidth = .025mm, offset = .1mm, + + functions = { + [ + code = "math.sind (50 * x - 150)", + close = true, + fillcolor = "MyColorR" + ], + [ + code = "math.cosd (50 * x - 150)", + close = true, + fillcolor = "MyColorB" + ] + }, + ] + xsized TextWidth + ; +\stopMPcode +\stopbuffer + +\typebuffer[3][option=TEX] + +\startplacefigure[reference=function:3] + \getbuffer[3] +\stopplacefigure + +It is important to choose a good step. In \in {figure} [function:4] we show 4 +variants and it is clear that in this case using straight line segments is better +(or at least more efficient with small steps). + +\startbuffer[4a] +\startMPcode{doublefun} + draw lmt_function [ + xmin = 0, xmax = 10, xstep = .1, + ymin = -1, ymax = 1, + + sx = 1mm, sy = 4mm, + + linewidth = .025mm, offset = .1mm, + + code = "math.sind (50 * x^2 - 150)", + shape = "curve" + ] + xsized .45TextWidth + ; +\stopMPcode +\stopbuffer + +\startbuffer[4b] +\startMPcode{doublefun} + draw lmt_function [ + xmin = 0, xmax = 10, xstep = .01, + ymin = -1, ymax = 1, + + sx = 1mm, sy = 4mm, + + linewidth = .025mm, offset = .1mm, + + code = "math.sind (50 * x^2 - 150)", + shape = "curve" + ] + xsized .45TextWidth + ; +\stopMPcode +\stopbuffer + +\startbuffer[4c] +\startMPcode{doublefun} + draw lmt_function [ + xmin = 0, xmax = 10, xstep = .1, + ymin = -1, ymax = 1, + + sx = 1mm, sy = 4mm, + + linewidth = .025mm, offset = .1mm, + + code = "math.sind (50 * x^2 - 150)", + shape = "line" + ] + xsized .45TextWidth + ; +\stopMPcode +\stopbuffer + +\startbuffer[4d] +\startMPcode{doublefun} + draw lmt_function [ + xmin = 0, xmax = 10, xstep = .01, + ymin = -1, ymax = 1, + + sx = 1mm, sy = 4mm, + + linewidth = .025mm, offset = .1mm, + + code = "math.sind (50 * x^2 - 150)", + shape = "line" + ] + xsized .45TextWidth + ; +\stopMPcode +\stopbuffer + +\typebuffer[4a][option=TEX] + +\startplacefigure[reference=function:4] + \startcombination[2*2] + {\getbuffer[4a]} {\type {xstep=.10} and \type {shape="curve"}} + {\getbuffer[4b]} {\type {xstep=.01} and \type {shape="curve"}} + {\getbuffer[4c]} {\type {xstep=.10} and \type {shape="line"}} + {\getbuffer[4d]} {\type {xstep=.01} and \type {shape="line"}} + \stopcombination +\stopplacefigure + +You can manipulate the axis (a bit) by tweaking the first and last ticks. In the +case of \in {figure} [function:5] we also put the shape on top of the axis. + +\startbuffer[5] +\startMPcode{doublefun} + draw lmt_function [ + xfirst = 9, xlast = 21, ylarge = 2, ysmall = 1/5, + yfirst = -1, ylast = 1, xlarge = 2, xsmall = 1/4, + + xmin = 10, xmax = 20, xstep = .25, + ymin = -1, ymax = 1, + + drawcolor = "darkmagenta", + shape = "steps", + code = "0.5 * math.random(-2,2)", + linewidth = .025mm, + offset = .1mm, + reverse = true, + ] + xsized TextWidth + ; +\stopMPcode +\stopbuffer + +\typebuffer[5][option=TEX] + +\startplacefigure[reference=function:5] + \getbuffer[5] +\stopplacefigure + +The whole repertoire of parameters (in case of doubt just check the source code as this +kind of code is not that hard to follow) is: + +\starttabulate[|T|T|T|p|] +\FL +\BC name \BC type \BC default \BC comment \NC \NR +\ML +\NC sx \NC numeric \NC 1mm \NC horizontal scale factor \NC \NR +\NC sy \NC numeric \NC 1mm \NC vertical scale factor \NC \NR +\NC offset \NC numeric \NC 0 \NC \NC \NR +\NC xmin \NC numeric \NC 1 \NC \NC \NR +\NC xmax \NC numeric \NC 1 \NC \NC \NR +\NC xstep \NC numeric \NC 1 \NC \NC \NR +\NC xsmall \NC numeric \NC \NC optional step of small ticks \NC \NR +\NC xlarge \NC numeric \NC \NC optional step of large ticks \NC \NR +\NC xlabels \NC string \NC no \NC \type {yes}, \type {no} or \type {nolimits} \NC \NR +\NC xticks \NC string \NC bottom \NC possible locations are \type {top}, \type {middle} and \type {bottom} \NC \NR +\NC xcaption \NC string \NC \NC \NC \NR +\NC ymin \NC numeric \NC 1 \NC \NC \NR +\NC ymax \NC numeric \NC 1 \NC \NC \NR +\NC ystep \NC numeric \NC 1 \NC \NC \NR +\NC ysmall \NC numeric \NC \NC optional step of small ticks \NC \NR +\NC ylarge \NC numeric \NC \NC optional step of large ticks \NC \NR +\NC xfirst \NC numeric \NC \NC left of \type {xmin} \NC \NR +\NC xlast \NC numeric \NC \NC right of \type {xmax} \NC \NR +\NC yfirst \NC numeric \NC \NC below \type {ymin} \NC \NR +\NC ylast \NC numeric \NC \NC above \type {ymax} \NC \NR +\NC ylabels \NC string \NC no \NC \type {yes}, \type {no} or \type {nolimits} \NC \NR +\NC yticks \NC string \NC left \NC possible locations are \type {left}, \type {middle} and \type {right} \NC \NR +\NC ycaption \NC string \NC \NC \NC \NR +\NC code \NC string \NC \NC \NC \NR +\NC close \NC boolean \NC false \NC \NC \NR +\NC shape \NC string \NC curve \NC or \type {line} \NC \NR +\NC fillcolor \NC string \NC \NC \NC \NR +\NC drawsize \NC numeric \NC 1 \NC \NC \NR +\NC drawcolor \NC string \NC \NC \NC \NR +\NC frame \NC string \NC \NC options are \type {yes}, \type {ticks} and \type {sticks} \NC \NR +\NC linewidth \NC numeric \NC .05mm \NC \NC \NR +\NC pointsymbol \NC string \NC \NC like type {dots} \NC \NR +\NC pointsize \NC numeric \NC 2 \NC \NC \NR +\NC pointcolor \NC string \NC \NC \NC \NR +\NC xarrow \NC string \NC \NC \NC \NR +\NC yarrow \NC string \NC \NC \NC \NR +\NC reverse \NC boolean \NC false \NC when \type {true} draw the function between axis and labels \NC \NR +\LL +\stoptabulate + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-grid.tex b/doc/context/sources/general/manuals/luametafun/luametafun-grid.tex new file mode 100644 index 000000000..719d8023d --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-grid.tex @@ -0,0 +1,11 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-grid + +\startchapter[title={Grid}] + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-interface.tex b/doc/context/sources/general/manuals/luametafun/luametafun-interface.tex new file mode 100644 index 000000000..662ae61a8 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-interface.tex @@ -0,0 +1,155 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-interface + +\startchapter[title={Interface}] + +Because graphic solutions are always kind of personal or domain driven it makes not +much sense to cook up very generic solutions. If you have a project where \METAPOST\ +can be of help, it also makes sense to spend some time on implementing the basics that +you need. In that case you can just copy and tweak what is there. The easiest way to +do that is to make a test file and use: + +\starttyping[option=TEX] +\startMPpage + % your code +\stopMPpage +\stoptyping + +Often you don't need to write macros, and standard drawing commands will do the +job, but when you find yourself repeating code, a wapper might make sense. And +this is why we have this key|/|value interface: it's easier to abstract your +settings than to pass them as (expression or text) arguments to a macro, +especially when there are many. + +You can find many examples of the key|/|value driven user interface in the source +files and these are actually not that hard to understand when you know a bit of +\METAPOST\ and the additional macros that come with \METAFUN. In case you wonder +about overhead: the performance of this mechanism is pretty good. + +Although the parameter handler runs on top of the \LUA\ interface, you don't need +to use \LUA\ unless you find that \METAPOST\ can't do the job. I won't give +examples of coding because I think that the source of \METAFUN\ provides enough +clues, especially the file \type {mp-lmtx.mpxl}. As the name suggests this is +part of the \CONTEXT\ version \LMTX, which runs on top of \LUAMETATEX. I leave it +open if I will backport this functionality to \LUATEX\ and therefore \MKIV. + +An excellent explanation of this interface can be found at: + +\starttyping +https://adityam.github.io/context-blog/post/new-metafun-interface/ +\stoptyping + +So (at least for now) here I can stick to just mentioning the currently stable +interface macros: + +\starttabulate[|T|l|pl|] +\FL +\NC presetparameters \NC \type {name [...]} \NC + Assign default values to a category of parameters. Sometimes it makes sense + not to set a default, because then you can check if a parameter has been set + at all. + \NC \NR +\NC applyparameters \NC \type {name macro} \NC + This prepares the parameter handler for the given category and calls the + given macro when that is done. + \NC \NR +\NC getparameters \NC \type {name [...]} \NC + The parameters given after the category name are set. + \NC \NR +\ML +\NC hasparameter \NC \type {names} \NC + Returns \type {true} when a parameter is set, and \type {false} otherwise. + \NC \NR +\NC hasoption \NC \type {names options} \NC + Returns \type {true} when there is overlap in given options, and \type + {false} otherwise. + \NC \NR +\ML +\NC getparameter \NC \type {names} \NC + Resolves the parameter with the given name. because a parameter itself can + have a parameter list you can pass additional names to reach the final + destination. + \NC \NR +\NC getparameterdefault \NC \type {names} \NC + Resolves the parameter with the given name. because a parameter itself can + have a parameter list you can pass additional names to reach the final + destination. The last value is used when no parameter is found. + \NC \NR +\ML +\NC getparametercount \NC \type {names} \NC + Returns the size if a list (array). + \NC \NR +\NC getmaxparametercount \NC \type {names} \NC + Returns the size if a list (array) but descends into lists to find the largest size + of a sublist. + \NC \NR +\ML +\NC getparameterpath \NC \type {names string boolean} \NC + Returns the parameter as path. The optional string is one of \type {--}, + \type {..} or \type {...} and the also optional boolean will force a closed + path. + \NC \NR +\NC getparameterpen \NC \type {names} \NC + Returns the parameter as pen (path). + \NC \NR +\NC getparametertext \NC \type {names boolean} \NC + Returns the parameter as string. The boolean can be used to force prepending + a so called \type {\strut}. + \NC \NR +\ML +\NC pushparameters \NC \type {category} \NC + Pushed the given (sub) category onto the stack so that we don't need to give + the category each time. + \NC \NR +\NC popparameters \NC \NC + Pops the current (sub) category from the stack. + \NC \NR +\LL +\stoptabulate + +Most commands accept a list of strings separated by one or more spaces, The +resolved will then stepwise descend into the parameter tree. This means that a +parameter itself can refer to a list. When a value is an array and the last name +is a number, the value at the given index will be returned. + +\starttyping +"category" "name" ... "name" +"category" "name" ... number +\stoptyping + +The \type {category} is not used when we have pushed a (sub) category which can +save you some typing and also is more efficient. Of course than can mean that you +need to store values at a higher level when you need them at a deeper level. + +There are quite some extra helpers that relate to this mechanism, at the +\METAPOST\ end as well as at the \LUA\ end. They aim for instance at efficiently +dealing with paths and can be seen at work in the mentioned module. + +There is one thing you should notice. While \METAPOST\ has numeric, string, +boolean and path variables that can be conveniently be passed to and from \LUA, +communicating colors is a bit of a hassle. This is because \RGB\ and \CMYK\ +colors and gray scales use different types. For this reason it is strongly +recommended to use strings that refer to predefined colors instead. This also +enforces consistency with the \TEX\ end. As convenience you can define colors at +the \METAFUN\ end. + +\startbuffer +\startMPcode + definecolor [ name = "MyColor", r = .5, g = .25, b = .25 ] + + fill fullsquare xyscaled (TextWidth,5mm) withcolor "MyColor" ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-introduction.tex b/doc/context/sources/general/manuals/luametafun/luametafun-introduction.tex new file mode 100644 index 000000000..6892b21ce --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-introduction.tex @@ -0,0 +1,88 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-introduction + +\startchapter[title={Introduction}] + +For quite a while, around since 1996, the integration of \METAPOST\ into +\CONTEXT\ became sort of mature but, it took decades of stepwise refinement to +reach the state that we're in now. In this manual I will discuss some of the +features that became possible by combining \LUA\ and \METAPOST. We already had +quite a bit of that for a decade but in 2018, when \LUAMETATEX\ showed up a next +stage was started. + +Before we go into details it is good to summarize the steps that were involved in +integrating \METAPOST\ and \TEX\ in \CONTEXT. It indicates a bit what we had and +have to deal with which in turn lead to the interfaces we now have. + +Originally, \TEX\ had no graphic capabilities: it just needed to know dimensions +of the graphics and pass some basic information about what to include to the +\DVI\ post processor. So, a \METAPOST\ graphic was normally processed outside the +current run, resulting in \POSTSCRIPT\ graphic, that then had to be included. In +\PDFTEX\ there were some more built in options, and therefore the \METAPOST\ code +could be processed runtime using some (generic) \TEX\ macros that I wrote. +However, that engine still had to launch \METAPOST\ for each graphic, although we +could accumulate them and do that between runs. Immediate processing means that +we immediately know the dimensions, while a collective run is faster. In \LUATEX\ +this all changed to very fast runtime processing, made possible because the +\METAPOST\ library is embedded in the engine, a decision that we made early in +the project and never regret. + +With \PDFTEX\ the process was managed by the \type {texexec} \CONTEXT\ runner but +with \LUATEX\ it stayed under the control of the current run. In the case of +\PDFTEX\ the actual embedding was done by \TEX\ macros that interpreted the +(relatively simple) \POSTSCRIPT\ code and turned it into \PDF\ literals. In +\LUATEX\ that job was delegated to \LUA. + +When using \PDFTEX\ with independent \METAPOST\ runs support for special color +spaces, transparency, embedded graphics, outline text, shading and more was +implemented using specials and special colors where the color served as reference +to some special extension. This works quite well. In \LUATEX\ the pre- and +postscript features, which are properties of picture objects, are used. + +In all cases, some information about the current run, for instance layout related +information, or color information, has to be passed to the rather isolated +\METAPOST\ run. In the case if \LUATEX\ (and \MKIV) the advantage is that +processing optional text happens in the same process so there we don't need to +pass information about for instance the current font setup. + +In \LUATEX\ the \METAPOST\ library has a \type {runscript} feature, which will +call \LUA\ with the given code. This permitted a better integration: we could now +ask for specific information (to the \TEX\ end) instead of passing it from the +\TEX\ end with each run. In \LUAMETATEX\ another feature was added: access to the +scanners from the \LUA\ end. Although we could already fetch some variables when +in \LUA\ this made it possible to extend the \METAPOST\ language in ways not +possible before. + +Already for a while Alan Braslau and I were working on some new \METAFUN\ code +that exploits all these new features. When the scanners came available I sat down +and started working on new interfaces and in this manual I will discuss some of +these. Some of them are illustrative, others are probably rather useful. The core +of what we could call \LUAMETAFUN\ (or \METAFUN\ XL when we use the file +extension as indicator) is a key|-|value interface as we have at the \TEX\ end. +This interface relates to \CONTEXT\ \LMTX\ development and therefore related +files have a different suffix: \type {mpxl}. However, keep in mind that some are +just wrappers around regular \METAPOST\ code so you have the full power of +traditional \METAPOST\ at hand. + +We can never satisfy all needs, so to some extent this manual also demonstrates +how to roll out your own code, but for that you also need to peek into the +\METAFUN\ source code too. It will take a while for this manual to complete. I +also expect other users to come up with solutions, so maybe in the end we will +have a collection of modules for specific tasks. + +\startlines +Hans Hagen +Hasselt NL +August 2019 (and beyond) +\stoplines + +\stopchapter + +\stopcomponent + +% I started writing this in 2019, a few days after seeing Wende live in Zeist ( +% (YT: WENDE - # MENS), one of the best shows of that year, a clear reminder of +% timeless versatility. diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-mesh-examples.tex b/doc/context/sources/general/manuals/luametafun/luametafun-mesh-examples.tex new file mode 100644 index 000000000..87f6d105f --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-mesh-examples.tex @@ -0,0 +1,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 diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-mesh.tex b/doc/context/sources/general/manuals/luametafun/luametafun-mesh.tex new file mode 100644 index 000000000..2fdb31250 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-mesh.tex @@ -0,0 +1,78 @@ +% language=us + +\environment luametafun-style +\environment luametafun-mesh-examples + +\startcomponent luametafun-mesh + +\startchapter[title={Mesh}] + +This is more a gimmick than of real practical use. A mesh is a set of paths that +gets transformed into hyperlinks. So, as a start you need to enable these: + +\starttyping[option=TEX] +\setupinteraction + [state=start, + color=white, + contrastcolor=white] +\stoptyping + +We just give a bunch of examples of meshes. A path is divided in smaller paths and +each of them is part of the same hyperlink. An application is for instance clickable +maps but (so far) only Acrobat supports such paths. + +\typebuffer[1][option=TEX] + +Such a definition is used as follows. First we define the mesh as overlay: + +\starttyping[option=TEX] +\defineoverlay[MyPath1][\useMPgraphic{MyPath1}] +\stoptyping + +Then, later on, this overlay can be used as background for a button. Here we just +jump to another page. The rendering is shown in \in {figure} [mesh:1]. + +\starttyping[option=TEX] +\button + [height=3cm, + width=4cm, + background=MyPath1, + frame=off] + {Example 1} + [realpage(2)] +\stoptyping + +\startplacefigure[reference=mesh:1] + \externalfigure[luametafun-mesh-examples][page=1,width=.45\textwidth] +\stopplacefigure + +More interesting are non|-|rectangular shapes so we show a bunch of them. You can +pass multiple paths, influence the accuracy by setting the number of steps and show +the mesh with the tracing option. + +\typebuffer[2][option=TEX] +\typebuffer[3][option=TEX] +\typebuffer[4][option=TEX] +\typebuffer[5][option=TEX] +\typebuffer[6][option=TEX] +\typebuffer[7][option=TEX] + +This is typical a feature that, if used at all, needs some experimenting but at +least the traced images look interesting enough. The six examples are shown in +\in {figure} [mesh:2]. + +\startplacefigure[reference=mesh:2] + \startcombination[2*3] + {\externalfigure[luametafun-mesh-examples][page=2,width=.45\textwidth]} {\type {MyPath2}} + {\externalfigure[luametafun-mesh-examples][page=3,width=.45\textwidth]} {\type {MyPath3}} + {\externalfigure[luametafun-mesh-examples][page=4,width=.45\textwidth]} {\type {MyPath4}} + {\externalfigure[luametafun-mesh-examples][page=5,width=.45\textwidth]} {\type {MyPath5}} + {\externalfigure[luametafun-mesh-examples][page=6,width=.45\textwidth]} {\type {MyPath6}} + {\externalfigure[luametafun-mesh-examples][page=7,width=.45\textwidth]} {\type {MyPath7}} + \stopcombination +\stopplacefigure + +\stopchapter + +\stopcomponent + diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-outline.tex b/doc/context/sources/general/manuals/luametafun/luametafun-outline.tex new file mode 100644 index 000000000..e2cdb4226 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-outline.tex @@ -0,0 +1,188 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-outline + +\startchapter[title={Outline}] + +In a regular text you can have outline characters by setting a (pseudo) font +feature but sometimes you want to play a bit more with this. In \METAFUN\ we +always had that option. In \MKII\ we call \type {pstoedit} to turn text into +outlines, in \MKIV\ we do that by manipulating the shapes directly. And, as with +some other extensions, in \LMTX\ a new interface has been added, but the +underlying code is the same as in \MKIV. + +\startbuffer[1a] +\startMPcode{doublefun} + draw lmt_outline [ + text = "hello" + kind = "draw", + drawcolor = "darkblue", + ] xsized .45TextWidth ; +\stopMPcode +\stopbuffer + +\startbuffer[1b] +\startMPcode{doublefun} + draw lmt_outline [ + text = "hello", + kind = "both", + fillcolor = "middlegray", + drawcolor = "darkgreen", + rulethickness = 1/5, + ] xsized .45TextWidth ; +\stopMPcode +\stopbuffer + +In \in {figure} [outline:1] we see two examples: + +\typebuffer[1a][option=TEX] + +and + +\typebuffer[1b][option=TEX] + +\startplacefigure[reference=outline:1,title={Drawing and|/|or filling an outline.}] + \startcombination + {\getbuffer[1a]} {\type {kind=draw}} + {\getbuffer[1b]} {\type {kind=both}} + \stopcombination +\stopplacefigure + +Normally the fill ends up below the draw but we can reverse the order, as in +\in {figure} [outline:2], where we coded the leftmost example as: + +\startbuffer[2a] +\startMPcode{doublefun} + draw lmt_outline [ + text = "hello", + kind = "reverse", + fillcolor = "darkred", + drawcolor = "darkblue", + rulethickness = 1/2, + ] xsized .45TextWidth ; +\stopMPcode +\stopbuffer + +\startbuffer[2b] +\startMPcode{doublefun} + draw lmt_outline [ + text = "hello", + kind = "both", + fillcolor = "darkred", + drawcolor = "darkblue", + rulethickness = 1/2, + ] xsized .45TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[2a][option=TEX] + +\startplacefigure[reference=outline:2,title={Reversing the order of drawing and filling.}] + \startcombination + {\getbuffer[2a]} {\type {kind=reverse}} + {\getbuffer[2b]} {\type {kind=both}} + \stopcombination +\stopplacefigure + +It is possible to fill and draw in one operation, in which case the same color is +used for both, see \in {figure} [outline:3] for an example fo this. This is a low +level optimization where the shape is only output once. + +\startbuffer[3a] +\startMPcode{doublefun} + draw lmt_outline [ + text = "hello", + kind = "fillup", + fillcolor = "darkgreen", + rulethickness = 1/5, + ] xsized .45TextWidth ; +\stopMPcode +\stopbuffer + +\startbuffer[3b] +\startMPcode{doublefun} + draw lmt_outline [ + text = "hello", + kind = "fill", + fillcolor = "darkgreen", + rulethickness = 1/5, + ] xsized .45TextWidth ; +\stopMPcode +\stopbuffer + +\startplacefigure[reference=outline:3,title={Combining a fill with a draw in the same color.}] + \startcombination + {\getbuffer[3a]} {\type {kind=fillup}} + {\getbuffer[3b]} {\type {kind=fill}} + \stopcombination +\stopplacefigure + + +This interface is much nicer than the one where each variant (the parameter \type +{kind} above) had its own macro due to the need to group properties of the +outline and fill. Let's show some more: + +\startbuffer[4] +\startMPcode{doublefun} + draw lmt_outline [ + text = "\obeydiscretionaries\samplefile{tufte}", + align = "normal", + kind = "draw", + drawcolor = "darkblue", + ] xsized TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[4][option=TEX] + +In this case we feed the text into the \type {\framed} macro so that we get a +properly aligned paragraph of text, as demonstrated in \in {figure} [outline:4] +\in {and} [outline:5]. If you want more trickery you can of course use any +\CONTEXT\ command (including \type {\framed} with all kind of options) in the +text. + +\startplacefigure[reference=outline:4,title={Outlining a paragraph of text.}] + \getbuffer[4] +\stopplacefigure + +\startbuffer[5] +\startMPcode{doublefun} + draw lmt_outline [ + text = "\obeydiscretionaries\samplefile{ward}", + align = "normal,tolerant", + style = "bold", + width = 10cm, + kind = "draw", + drawcolor = "darkblue", + ] xsized TextWidth ; +\stopMPcode +\stopbuffer + +\typebuffer[5][option=TEX] + +\startplacefigure[reference=outline:4,title={Outlining a paragraph of text with a specific width.}] + \getbuffer[5] +\stopplacefigure + +We summarize the parameters: + +\starttabulate[|T|T|T|p|] +\FL +\BC name \BC type \BC default \BC comment \NC \NR +\ML +\NC text \NC string \NC \NC \NC \NR +\NC kind \NC string \NC draw \NC One of \type {draw}, \type {fill}, \type {both}, \type {reverse} and \type {fillup}. \NC \NR +\NC fillcolor \NC string \NC \NC \NC \NR +\NC drawcolor \NC string \NC \NC \NC \NR +\NC rulethickness \NC numeric \NC 1/10 \NC \NC \NR +\NC align \NC string \NC \NC \NC \NR +\NC style \NC string \NC \NC \NC \NR +\NC width \NC numeric \NC \NC \NC \NR +\LL +\stoptabulate + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-placeholder.tex b/doc/context/sources/general/manuals/luametafun/luametafun-placeholder.tex new file mode 100644 index 000000000..3627bbfd0 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-placeholder.tex @@ -0,0 +1,163 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-placeholder + +\startchapter[title={Placeholder}] + +Placeholders are an old \CONTEXT\ features and have been around since we started using +\METAPOST. They are used as dummy figure, just in case one is not (yet) present. They +are normally activated by loading a \METAFUN\ library: + +\starttyping[option=TEX] +\useMPLibrary[dum] +\stoptyping + +Just because it could be done conveniently, placeholders are now defined at the +\METAPOST\ end instead of as useable \METAPOST\ graphic at the \TEX\ end. The +variants and options are demonstrated using side floats. + +\startbuffer[1] +\startMPcode + lmt_placeholder [ + width = 4cm, + height = 3cm, + color = "red", + alternative = "circle". + ] ; +\stopMPcode +\stopbuffer + +\startplacefigure[location=left] + \getbuffer[1] +\stopplacefigure + +\typebuffer[1][option=TEX] + +In addition to the traditional random circle we now also provide rectangles +and triangles. Maybe some day more variants will show up. + +\startbuffer[2] +\startMPcode + lmt_placeholder [ + width = 4cm, + height = 3cm, + color = "green", + alternative = "square". + ] ; +\stopMPcode +\stopbuffer + +\startplacefigure[location=left] + \getbuffer[2] +\stopplacefigure + +\typebuffer[2][option=TEX] + +Here we set the colors but in the image placeholder mechanism we cycle through +colors automatically. Here we use primary, rather dark, colors. + +\startbuffer[3] +\startMPcode + lmt_placeholder [ + width = 4cm, + height = 3cm, + color = "blue", + alternative = "triangle". + ] ; +\stopMPcode +\stopbuffer + +\startplacefigure[location=left] + \getbuffer[3] +\stopplacefigure + +\typebuffer[3][option=TEX] + +\startbuffer[4a] +\startMPcode + lmt_placeholder [ + width = 4cm, + height = 3cm, + color = "yellow", + alternative = "circle". + reduction = 0, + ] ; +\stopMPcode +\stopbuffer + +\startbuffer[4b] +\startMPcode + lmt_placeholder [ + width = 4cm, + height = 3cm, + color = "yellow", + alternative = "circle". + reduction = 0.25, + ] ; +\stopMPcode +\stopbuffer + +\startbuffer[4c] +\startMPcode + lmt_placeholder [ + width = 4cm, + height = 3cm, + color = "yellow", + alternative = "circle". + reduction = 0.50, + ] ; +\stopMPcode +\stopbuffer + +\startbuffer[4d] +\startMPcode + lmt_placeholder [ + width = 4cm, + height = 3cm, + color = "yellow", + alternative = "circle". + reduction = 0.75, + ] ; +\stopMPcode +\stopbuffer + +If you want less dark colors, the \type {reduction} parameter can be used to +interpolate between the given color and white; its value is therefore a value +between zero (default) and 1 (rather pointless as it produces white). + +\startplacefigure[location=left] + \startcombination[2*2] + {\getbuffer[4a]} {0} + {\getbuffer[4b]} {0.25} + {\getbuffer[4c]} {0.50} + {\getbuffer[4d]} {0.75} + \stopcombination +\stopplacefigure + +We demonstrate this with four variants, all circles. Of course you can also use +lighter colors, but this option was needed for the image placeholders anyway. + +\typebuffer[4b][option=TEX] + +\flushsidefloats + +There are only a few possible parameters. As you can see, proper dimensions need +to be given because the defaults are pretty small. + +\starttabulate[|T|T|T|p|] +\FL +\BC name \BC type \BC default \BC comment \NC \NR +\ML +\NC color \NC string \NC red \NC \NC \NR +\NC width \NC numeric \NC 1 \NC \NC \NR +\NC height \NC numeric \NC 1 \NC \NC \NR +\NC reduction \NC numeric \NC 0 \NC \NC \NR +\NC alternative \NC string \NC circle \NC \NC \NR +\LL +\stoptabulate + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-shade.tex b/doc/context/sources/general/manuals/luametafun/luametafun-shade.tex new file mode 100644 index 000000000..a139be954 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-shade.tex @@ -0,0 +1,230 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-shade + +\startchapter[title={Shade}] + +{\em This interface is still experimental!} + +Shading is complex. We go from one color to another on a continuum either linear +or circular. We have to make sure that we cover the whole shape and that means +that we have to guess a little, although one can influence this with parameters. +It can involve a bit of trial and error, which is more complex that using a +graphical user interface but this is the price we pay. It goes like this: + +\startbuffer[1] +\startMPcode +definecolor [ name = "MyColor3", r = 0.22, g = 0.44, b = 0.66 ] ; +definecolor [ name = "MyColor4", r = 0.66, g = 0.44, b = 0.22 ] ; + +draw lmt_shade [ + path = fullcircle scaled 4cm, + direction = "right", + domain = { 0, 2 }, + colors = { "MyColor3", "MyColor4" }, +] ; + +draw lmt_shade [ + path = fullcircle scaled 3cm, + direction = "left", + domain = { 0, 2 }, + colors = { "MyColor3", "MyColor4" }, +] shifted (45mm,0) ; + +draw lmt_shade [ + path = fullcircle scaled 5cm, + direction = "up", + domain = { 0, 2 }, + colors = { "MyColor3", "MyColor4" }, +] shifted (95mm,0) ; + +draw lmt_shade [ + path = fullcircle scaled 1cm, + direction = "down", + domain = { 0, 2 }, + colors = { "MyColor3", "MyColor4" }, +] shifted (135mm,0) ; +\stopMPcode +\stopbuffer + +\typebuffer[1][option=TEX] + +Normally this is good enough as demonstrated in \in {figure} [shade:1] because +we use shades as backgrounds. In the case of a circular shade we need to tweak +the domain because guessing doesn't work well. + +\startplacefigure[reference=shade:1,title={Simple circular shades.}] + \getbuffer[1] +\stopplacefigure + +\startbuffer[2] +\startMPcode +draw lmt_shade [ + path = fullsquare scaled 4cm, + alternative = "linear", + direction = "right", + colors = { "MyColor3", "MyColor4" }, +] ; + +draw lmt_shade [ + path = fullsquare scaled 3cm, + direction = "left", + alternative = "linear", + colors = { "MyColor3", "MyColor4" }, +] shifted (45mm,0) ; + +draw lmt_shade [ + path = fullsquare scaled 5cm, + direction = "up", + alternative = "linear", + colors = { "MyColor3", "MyColor4" }, +] shifted (95mm,0) ; + +draw lmt_shade [ + path = fullsquare scaled 1cm, + direction = "down", + alternative = "linear", + colors = { "MyColor3", "MyColor4" }, +] shifted (135mm,0) ; +\stopMPcode +\stopbuffer + +\typebuffer[2][option=TEX] + +\startplacefigure[reference=shade:2,title={Simple rectangular shades.}] + \getbuffer[2] +\stopplacefigure + +The \type {direction} relates to the boundingbox. Instead of a keyword you can +also give two values, indicating points on the boundingbox. Because a boundingbox +has four points, the \type {up} direction is equivalent to \type {{0.5,2.5}}. + +The parameters \type {center}, \type {factor}, \type {vector} and \type {domain} +are a bit confusing but at some point the way they were implemented made sense, +so we keep them as they are. The center moves the center of the path that is used +as anchor for one color proportionally to the bounding box: the given factor is +multiplied by half the width and height. + +\startbuffer[3] +\startMPcode +draw lmt_shade [ + path = fullcircle scaled 5cm, + domain = { .2, 1.6 }, + center = { 1/10, 1/10 }, + direction = "right", + colors = { "MyColor3", "MyColor4" }, + trace = true, +] ; +\stopMPcode +\stopbuffer + +\typebuffer[3][option=TEX] + +\startplacefigure[reference=shade:3,title={Moving the centers.}] + \getbuffer[3] +\stopplacefigure + +A vector takes the given points on the path as centers for the colors, see \in +{figure} [shade:4]. + +\startbuffer[4] +\startMPcode +draw lmt_shade [ + path = fullcircle scaled 5cm, + domain = { .2, 1.6 }, + vector = { 2, 4 }, + direction = "right", + colors = { "MyColor3", "MyColor4" }, + trace = true, +] ; +\stopMPcode +\stopbuffer + +\typebuffer[4][option=TEX] + +\startplacefigure[reference=shade:4,title={Using a vector (points).}] + \getbuffer[4] +\stopplacefigure + +Messing with the radius in combination with the previously mentioned domain +is really trial and error, as seen in \in {figure} [shade:5]. + +\startbuffer[5] +\startMPcode +draw lmt_shade [ + path = fullcircle scaled 5cm, + domain = { 0.5, 2.5 }, + radius = { 2cm, 6cm }, + direction = "right", + colors = { "MyColor3", "MyColor4" }, + trace = true, +] ; +\stopMPcode +\stopbuffer + +\typebuffer[5][option=TEX] + +\startplacefigure[reference=shade:5,title={Tweaking the radius.}] + \getbuffer[5] +\stopplacefigure + +But actually the radius used alone works quite well as shown in \in {figure} +[shade:6]. + +\startbuffer[6] +\startMPcode +draw lmt_shade [ + path = fullcircle scaled 5cm, + colors = { "red", "green" }, + trace = true, +] ; + +draw lmt_shade [ + path = fullcircle scaled 5cm, + colors = { "red", "green" }, + radius = 2.5cm, + trace = true, +] shifted (6cm,0) ; + +draw lmt_shade [ + path = fullcircle scaled 5cm, + colors = { "red", "green" }, + radius = 2.0cm, + trace = true, +] shifted (12cm,0) ; +\stopMPcode +\stopbuffer + +\typebuffer[6][option=TEX] + +\startplacefigure[reference=shade:6,title={Just using the radius.}] + \getbuffer[6] +\stopplacefigure + +\starttabulate[|T|T|T|p|] +\FL +\BC name \BC type \BC default \BC comment \NC \NR +\ML +\NC alternative \NC string \NC circular \NC or \type {linear} \NC \NR +\NC path \NC path \NC \NC \NC \NR +\NC trace \NC boolean \NC false \NC \NC \NR +\NC domain \NC set of numerics \NC \NC \NC \NR +\NC radius \NC numeric \NC \NC \NC \NR +\NC \NC set of numerics \NC \NC \NC \NR +\NC factor \NC numeric \NC \NC \NC \NR +\NC origin \NC pair \NC \NC \NC \NR +\NC \NC set of pairs \NC \NC \NC \NR +\NC vector \NC set of numerics \NC \NC \NC \NR +\NC colors \NC set of strings \NC \NC \NC \NR +\NC center \NC numeric \NC \NC \NC \NR +\NC \NC set of numerics \NC \NC \NC \NR +\NC direction \NC string \NC \NC \type{up}, \type {down}, \type {left}, \type {right} \NC \NR +\NC \NC set of numerics \NC \NC two points on the boundingbox \NC \NR +\LL +\stoptabulate + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-style.tex b/doc/context/sources/general/manuals/luametafun/luametafun-style.tex new file mode 100644 index 000000000..df469d0c0 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-style.tex @@ -0,0 +1,55 @@ +\startenvironment luametafun-style + +\usemodule[abbreviations-smallcaps] + +\usemodule[scite] + +\setupbodyfont + [ibmplex,rm,10pt] + +\setupwhitespace + [big] + +\setuplayout + [topspace=10mm, + bottomspace=1cm, + backspace=2cm, + footerdistance=10mm, + footer=1cm, + % headerdistance=10mm, + % header=1cm, + topspace=20mm, + headerdistance=0mm, + header=0cm, + height=middle, + width=middle] + +\setupalign + [verytolerant] + +\setupheadertexts + [] + +\setupfootertexts + [chapter][pagenumber] + +\setuphead + [chapter] + [color=darkgray, + style=\bfd] + +\setuphead + [section] + [color=darkgray, + style=\bfc] + +\setupfooter + [color=darkgray, + style=\bf] + +\setuplist + [chapter] + [before=, + after=] + +\stopenvironment diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-svg.tex b/doc/context/sources/general/manuals/luametafun/luametafun-svg.tex new file mode 100644 index 000000000..f7aba06fd --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-svg.tex @@ -0,0 +1,75 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-svg + +\startchapter[title={SVG}] + +There is not that much to tell about this command. It translates an \SVG\ image +to \METAPOST\ operators. We took a few images from a mozilla emoji font: + +\startbuffer[2] +\startMPcode + draw lmt_svg [ + filename = "mozilla-svg-002.svg", + height = 2cm, + width = 8cm, + ] ; +\stopMPcode +\stopbuffer + +\typebuffer[2][option=TEX] + +\startlinecorrection + \getbuffer[2] +\stoplinecorrection + +Because we get pictures, you can do mess around with them: + +\startbuffer[1] +\startMPcode + picture p ; p := lmt_svg [ filename = "mozilla-svg-001.svg" ] ; + numeric w ; w := bbwidth(p) ; + draw p ; + draw p xscaled -1 shifted (2.5*w,0); + draw p rotatedaround(center p,45) shifted (3.0*w,0) ; + draw image ( + for i within p : if filled i : + draw pathpart i withcolor green ; + fi endfor ; + ) shifted (4.5*w,0); + draw image ( + for i within p : if filled i : + fill pathpart i withcolor red withtransparency (1,.25) ; + fi endfor ; + ) shifted (6*w,0); +\stopMPcode +\stopbuffer + +\typebuffer[1][option=TEX] + +\startlinecorrection + \getbuffer[1] +\stoplinecorrection + +Of course. often you won't know in advance what is inside the image and how (well) +it has been defined so the previous example is more about showing some \METAPOST\ +muscle. + +The supported parameters are: + +\starttabulate[|T|T|T|p|] +\FL +\BC name \BC type \BC default \BC comment \NC \NR +\ML +\NC filename \NC path \NC \NC \NC \NR +\NC width \NC numeric \NC \NC \NC \NR +\NC height \NC numeric \NC \NC \NC \NR +\LL +\stoptabulate + +\stopchapter + +\stopcomponent + diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-text.tex b/doc/context/sources/general/manuals/luametafun/luametafun-text.tex new file mode 100644 index 000000000..4f08ee00f --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-text.tex @@ -0,0 +1,137 @@ +% language=us + +\environment luametafun-style + +\startcomponent luametafun-text + +\startchapter[title={Text}] + +The \METAFUN\ \type {textext} command normally can do the job of typesetting a +text snippet quite well. + +\startbuffer +\startMPcode + fill fullcircle xyscaled (8cm,1cm) withcolor "darkred" ; + draw textext("\bf This is text A") withcolor "white" ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +We get: + +\startlinecorrection +\getbuffer +\stoplinecorrection + +You can use regular \CONTEXT\ commands, so this is valid: + +\startbuffer +\startMPcode + fill fullcircle xyscaled (8cm,1cm) withcolor "darkred" ; + draw textext("\framed{\bf This is text A}") withcolor "white" ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +Of course you can as well draw a frame in \METAPOST\ but the \type {\framed} +command has more options, like alignments. + +\startlinecorrection +\getbuffer +\stoplinecorrection + +Here is a variant using the \METAFUN\ interface: + +\startbuffer +\startMPcode + fill fullcircle xyscaled (8cm,1cm) withcolor "darkred" ; + draw lmt_text [ + text = "This is text A", + color = "white", + style = "bold" + ] ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +The outcome is more or less the same: + +\startlinecorrection +\getbuffer +\stoplinecorrection + +Here is another example. The \type {format} option is actually why this command +is provided. + +\startbuffer +\startMPcode + fill fullcircle xyscaled (8cm,1cm) withcolor "darkred" ; + draw lmt_text [ + text = decimal 123.45678, + color = "white", + style = "bold", + format = "@0.3F", + ] ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + +The following parameters can be set: + +\starttabulate[|T|T|T|p|] +\FL +\BC name \BC type \BC default \BC comment \NC \NR +\ML +\NC offset \NC numeric \NC 0 \NC \NC \NR +\NC strut \NC string \NC auto \NC adapts the dimensions to the font (\type {yes} uses the the default strut) \NC \NR +\NC style \NC string \NC \NC \NC \NR +\NC color \NC string \NC \NC \NC \NR +\NC text \NC string \NC \NC \NC \NR +\NC anchor \NC string \NC \NC one of these \type {lft}, \type {urt} like anchors \NC \NR +\NC format \NC string \NC \NC a format specifier using \type {@} instead of a percent sign \NC \NR +\NC position \NC pair \NC origin \NC \NC \NR +\NC trace \NC boolean \NC false \NC \NC \NR +\LL +\stoptabulate + +The next example demonstrates the positioning options: + +\startbuffer +\startMPcode + fill fullcircle xyscaled (8cm,1cm) withcolor "darkblue" ; + fill fullcircle scaled .5mm withcolor "white" ; + draw lmt_text [ + text = "left", + color = "white", + style = "bold", + anchor = "lft", + position = (-1mm,2mm), + ] ; + draw lmt_text [ + text = "right", + color = "white", + style = "bold", + anchor = "rt", + offset = 3mm, + ] ; +\stopMPcode +\stopbuffer + +\typebuffer[option=TEX] + +\startlinecorrection +\getbuffer +\stoplinecorrection + + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun-titlepage.tex b/doc/context/sources/general/manuals/luametafun/luametafun-titlepage.tex new file mode 100644 index 000000000..4450199e6 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun-titlepage.tex @@ -0,0 +1,41 @@ + +\environment luametafun-style + +\startcomponent luametafun-titlepage + +\startMPpage + + fill Page withcolor "darkblue" ; + + path p ; p := (0,0) -- (0,4) -- (2,2) -- (4,4) -- (4,0) ; + + p := p scaled 20; p := p shifted - center p ; + + draw image ( + for i=1 upto 1000 : + draw p shifted (center Page randomized urcorner Page) ; + endfor ; + ) withcolor "darkgreen" ; + + setbounds currentpicture to Page ; + + draw + % textext.ulft("\ss luametafun") + textext.ulft("\ss metafun xl") + xsized .55bbwidth(Page) + shifted lrcorner Page + shifted (-15mm,35mm) + withcolor "white" + ; + + draw + textext.ulft("\ss Hans Hagen") + xsized .3bbwidth(Page) + shifted lrcorner Page + shifted (-15mm,15mm) + withcolor "white" + ; + +\stopMPpage + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/luametafun.tex b/doc/context/sources/general/manuals/luametafun/luametafun.tex new file mode 100644 index 000000000..0e298dcd0 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/luametafun.tex @@ -0,0 +1,31 @@ +\setupfootertexts[{\tttf uncorrected draft}] + +\environment luametafun-style + +\startcomponent luametafun + + \component luametafun-titlepage + + \startfrontmatter + \component luametafun-contents + \component luametafun-introduction + \stopfrontmatter + + \startbodymatter + \component luametafun-text + \component luametafun-function + \component luametafun-contour + % \component luametafun-grid + \component luametafun-axis + \component luametafun-outline + \component luametafun-followtext + \component luametafun-placeholder + \component luametafun-arrow + \component luametafun-chart + \component luametafun-mesh + \component luametafun-shade + \component luametafun-svg + \component luametafun-interface + \stopbodymatter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/luametafun/mozilla-svg-001.svg b/doc/context/sources/general/manuals/luametafun/mozilla-svg-001.svg new file mode 100644 index 000000000..f74af7dd1 --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/mozilla-svg-001.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg"><path fill="#d87512" d="M17.786 44.63c-.606.115-1.23.173-1.854.173-2.444 0-4.644-.864-6.04-2.375-.855-.92-1.394-2.147-1.517-3.47-.126-1.243.067-2.638.58-4.163.325-1.016.83-2.01 1.365-3.064.216-.426.437-.858.65-1.302.702-1.454 1.504-3.164 2.11-5.05.715-2.188.943-4.287.682-6.23-.267-2.102-.994-3.972-1.74-5.685a2.992 2.992 0 0 0-4.15-1.446c-.71.375-1.23 1-1.467 1.77a2.983 2.983 0 0 0 .218 2.292c.632 1.19 1.314 2.596 1.592 3.977.238 1.137.18 2.41-.184 3.897-.37 1.538-.976 3.143-1.522 4.518-.16.406-.33.816-.507 1.234-.507 1.215-1.032 2.47-1.364 3.838-.55 2.14-.666 4.152-.348 5.97.36 2.163 1.41 4.14 2.955 5.567 2.027 1.88 4.808 2.914 7.826 2.914 1.14 0 2.274-.146 3.375-.437l-.66-2.923"/><g fill="#bc600d"><path d="M11.585 43.742s.387 1.248.104 3.05c0 0 2.045-.466 1.898-2.27 0 0-.815-.29-2-.78M9.19 41.484S8.98 42.94 7.93 44.43c0 0 2.103.42 2.774-1.265 0 0-.696-.66-1.515-1.68M8.398 37.21s-.926 1.432-3.23 2.322c0 0 1.514 2.303 3.53.904 0 0-.237-1.388-.3-3.226M12.964 15.833s-1.685.798-3.783 3.45c0 0 2.1 1.55 4.663 2.228 0 0 .285-3.093-.88-5.677M13.5 23.873s-2.988.544-5.57 2.794c0 0 1.615 1.708 3.583 2.62 0 0 1.678-3.39 1.987-5.414M10.32 31.73s-1.483 0-4.483.812c0 0-.01 2.873 2.94 2.823 0 0 .747-1.75 1.544-3.635"/></g><g fill="#d87512"><path d="M53.33 39.37c0-4.484-35.622-4.484-35.622 0 0 10.16.05 10.25 17.81 10.25 17.762 0 17.812-.09 17.812-10.25"/><path d="M42.645 56.04c1.688 2.02 9.275.043 10.504-2.28 5.01-9.482-.006-13.58-.006-13.58l-10.5 1.313s-2.154 11.977 0 14.547"/></g><g fill="#bc600d"><path d="M54.2 41.496s-.336 4.246-4.657 9.573c0 0 4.38-1.7 5.808-4.3 0 0 .448-3.02-1.15-5.274M55.08 48.69s-1.065 1.88-3.563 3.872c0 0 1.78-.03 2.576-.785 0 0 .77-1.41.987-3.086"/></g><path fill="#f29a2e" d="M35.484 60.38c1.87 2.23 8.547 2.09 10.574 0 2.904-2.995 2.78-16.656 2.904-23.314l-12.418-1.053s-3.444 21.52-1.06 24.367"/><g fill="#bc600d"><path d="M48.21 53.53s-3.578-3.443-8.738-.013c0 0 5.754 2.455 7.365 5.672 0 0 1.126-2.245 1.373-5.66M48.775 46.06s-3.852-3.09-7.938 1.43c0 0 4.452-.47 7.632 3.635 0 0 .493-3.05.305-5.065"/></g><g fill="#3e4347"><path d="M43.847 61.57l-.397-2.765 1.344 2.445zM40.41 61.996l.502-3.294.498 3.294zM36.713 61.3l1.317-2.26-.372 2.59z"/></g><path fill="#d87512" d="M28.388 56.04c-1.688 2.02-9.277.043-10.504-2.28-5.01-9.482.004-13.58.004-13.58l10.5 1.313s2.154 11.977 0 14.547"/><g fill="#bc600d"><path d="M16.833 41.496s.336 4.246 4.657 9.573c0 0-4.38-1.7-5.807-4.3 0 0-.448-3.02 1.15-5.274M15.957 48.69s1.066 1.88 3.563 3.872c0 0-1.782-.03-2.576-.785 0 0-.772-1.41-.987-3.086"/></g><path fill="#f29a2e" d="M35.548 60.38c-1.87 2.23-8.548 2.09-10.575 0-2.904-2.995-2.78-16.656-2.904-23.314l12.417-1.053s3.446 21.52 1.06 24.367"/><g fill="#bc600d"><path d="M22.822 53.53s3.58-3.443 8.74-.013c0 0-5.754 2.455-7.367 5.672 0 0-1.125-2.245-1.373-5.66M22.255 46.06s3.852-3.09 7.94 1.43c0 0-4.453-.47-7.633 3.635 0 0-.493-3.05-.307-5.065"/></g><g fill="#3e4347"><path d="M26.24 61.25l1.345-2.445-.395 2.765zM29.62 61.996l.5-3.294.5 3.294zM33.375 61.63L33 59.04l1.32 2.26zM35.516 60.46c-.395-2.48-.482-4.96-.5-7.438.015-2.48.104-4.96.5-7.44.396 2.48.485 4.96.5 7.44-.018 2.48-.106 4.96-.5 7.438"/></g><path fill="#f29a2e" d="M27.777 6.994c0 3.82-2.727 6.987-6.086 6.915C11.83 13.7 15.893 2 15.893 2c3.36 0 11.885 1.176 11.885 4.994"/><path fill="#af5a31" d="M24.05 7.752c0 2.037-1.454 3.727-3.248 3.688-5.26-.11-3.093-6.353-3.093-6.353 1.792 0 6.34.628 6.34 2.665"/><path fill="#f29a2e" d="M43.26 6.994c0 3.82 2.726 6.987 6.086 6.915 9.86-.21 5.8-11.91 5.8-11.91C51.782 2 43.26 3.176 43.26 6.994"/><path fill="#af5a31" d="M46.983 7.752c0 2.037 1.455 3.727 3.247 3.688 5.26-.11 3.094-6.353 3.094-6.353-1.794 0-6.34.628-6.34 2.665"/><path fill="#f29a2e" d="M55.806 33.378c0 7.155-9.517 8.13-20.288 8.13-10.776 0-20.29-.975-20.29-8.13 0-29.96 11.596-29.14 20.29-29.14 8.69 0 20.288-.82 20.288 29.14"/><g fill="#3e4347"><path d="M35.54 7.59c3.24 0 6.15 1.084 8.156 2.81-.77-2.945-4.135-5.16-8.173-5.16-4.06 0-7.442 2.238-8.186 5.204 2.01-1.753 4.938-2.855 8.204-2.855"/><path d="M35.535 11.193c2.217 0 4.21.744 5.584 1.925-.528-2.02-2.835-3.534-5.6-3.534-2.78 0-5.095 1.533-5.605 3.564 1.376-1.198 3.383-1.955 5.62-1.955"/></g><path fill="#ffe8bb" d="M29.553 43.727l-18.408-7.01 4.24-9.06s2.704 3.85 13.29 6.82l.878 9.243"/><path fill="#3e4347" d="M29.37 39.77c-7.462-1.27-16.325-6.673-16.48-6.75l.992-2.168c.184.092 8.806 5.342 15.853 6.544l-.366 2.374"/><path fill="#ffe8bb" d="M41.48 43.727l18.406-7.01-4.24-9.06s-2.704 3.85-13.29 6.82l-.876 9.243"/><path fill="#3e4347" d="M41.663 39.77c7.46-1.27 16.325-6.673 16.48-6.75l-.993-2.168c-.184.092-8.808 5.342-15.852 6.544l.365 2.374"/><g fill="#ffe8bb"><path d="M43.524 45.57C38.752 42.023 41.4 33.86 41.4 33.86c-5.657 5.906-12.662 8.74-12.662 8.74 1.608 5.446 5.77 6.412 5.77 6.412-.34-1.835.663-3.302.663-3.302 1.68 2.22 5.03 2.986 5.03 2.986-1.287-1.508-.948-3.835-.948-3.835 2.326.875 4.27.71 4.27.71"/><path d="M42.29 42.97c-2.634 2.247-10.917 2.247-13.553 0-2.856-2.435-2.495-7.144.1-9.884 2.397-2.527 10.958-2.527 13.355 0 2.595 2.74 2.956 7.45.098 9.883"/></g><g fill="#3e4347"><path d="M36.18 40.48a.69.69 0 0 1-.644-.477c-.227-.67-.77-3.293-.71-5.498.01-.398.325-.71.7-.698.38.01.674.343.663.74-.057 2.01.46 4.466.633 4.974.127.375-.06.786-.414.92a.607.607 0 0 1-.23.04"/><path d="M30.504 43.25c.21-.202.394-.408.582-.61.188-.204.378-.405.57-.604.385-.396.782-.78 1.2-1.145a14.125 14.125 0 0 1 2.745-1.9c.504-.263 1.032-.49 1.59-.654s1.153-.273 1.772-.253c.31.01.623.055.928.146.307.088.602.23.86.416.263.19.485.422.652.684.17.257.287.54.35.83a4.247 4.247 0 0 0-.677-.448 2.567 2.567 0 0 0-.68-.237c-.447-.088-.887-.04-1.33.06-.89.216-1.786.65-2.69 1.114-.905.466-1.818.983-2.776 1.466-.48.24-.97.473-1.48.682-.256.103-.517.202-.783.285-.27.078-.546.155-.833.167"/></g><path fill="#f15a61" d="M41.34 31.743c-1.17-.528-4.757-.57-5.83-.57-1.07 0-4.66.042-5.83.57-.832.376-.187 1.31 2.027 2.116 1.397.506 2.733.666 3.803.666 1.07 0 2.405-.16 3.805-.667 2.213-.808 2.856-1.74 2.025-2.117"/><g fill="#3e4347"><path d="M29.917 23.48l1.61 5.292L26.954 26z"/><path d="M22.645 31.828c-.522 0-.932-.056-1.17-.098-2.986-.52-4.632-1.996-6.09-4.067l.185-2.472c1.52 1.446 3.953 3.76 6.28 4.167 1.156.2 2.853-.016 4.15-1.234 1.537-1.44 2.263-4.05 2.1-7.547l1.635.132c.2 4.312-.116 7.244-2.212 9.212-1.692 1.59-3.613 1.908-4.878 1.908M41.12 23.48l-1.613 5.292L44.08 26z"/><path d="M48.39 31.828c.52 0 .93-.056 1.167-.098 2.99-.52 4.637-1.996 6.09-4.067l-.182-2.472c-1.52 1.446-3.955 3.76-6.28 4.167-1.156.2-2.855-.016-4.154-1.234-1.532-1.44-2.258-4.05-2.095-7.547l-1.636.132c-.202 4.312.114 7.244 2.213 9.212 1.69 1.59 3.61 1.908 4.877 1.908"/></g><path fill="#ffe8bb" d="M30.25 22.09c-.852 5.282-3.728 5.87-6.696 5.577-2.986-.294-5.396-2.667-5.396-6.743 0-4.28 0-4.28 6.647-5.752 6.728-1.49 6 3.437 5.445 6.918"/><path fill="#3e4347" d="M29.16 22.547c-.244 2.534-2.61 4.357-5.287 4.072-2.674-.286-4.645-2.57-4.402-5.102s.28-2.75 5.108-2.237c4.83.514 4.824.737 4.582 3.267"/><path fill="#fff" d="M27.59 21.884c-.16 1.688-1.74 2.903-3.522 2.714-1.785-.19-3.096-1.712-2.936-3.4.163-1.69.186-1.835 3.406-1.493 3.22.344 3.215.49 3.053 2.18"/><g fill="#3e4347"><ellipse cx="25.5" cy="21.08" rx="1.45" ry="1.647"/><path d="M31.27 17.896c.42 0 .807-.284.936-.728.16-.546-.133-1.122-.65-1.29l-5.98-1.924c-.516-.166-1.065.14-1.225.685-.155.543.136 1.12.652 1.287l5.98 1.924a.95.95 0 0 0 .288.046"/></g><path fill="#ffe8bb" d="M40.78 22.09c.855 5.282 3.73 5.87 6.7 5.577 2.984-.294 5.395-2.667 5.395-6.743 0-4.28-.002-4.28-6.646-5.752-6.73-1.49-6.01 3.437-5.45 6.918"/><path fill="#3e4347" d="M41.873 22.547c.243 2.534 2.61 4.357 5.287 4.072 2.674-.286 4.646-2.57 4.402-5.102-.242-2.533-.28-2.75-5.107-2.237-4.83.514-4.824.737-4.582 3.267"/><path fill="#fff" d="M43.44 21.884c.16 1.688 1.737 2.903 3.522 2.714 1.783-.19 3.098-1.712 2.936-3.4-.16-1.69-.188-1.835-3.404-1.493-3.22.344-3.217.49-3.054 2.18"/><g fill="#3e4347"><ellipse cx="47.722" cy="20.932" rx="1.45" ry="1.647"/><path d="M39.76 17.896a.982.982 0 0 1-.935-.728c-.16-.546.132-1.122.65-1.29l5.98-1.924c.517-.166 1.063.14 1.224.685.155.543-.136 1.12-.653 1.287l-5.98 1.924a.96.96 0 0 1-.287.046"/></g></svg> diff --git a/doc/context/sources/general/manuals/luametafun/mozilla-svg-002.svg b/doc/context/sources/general/manuals/luametafun/mozilla-svg-002.svg new file mode 100644 index 000000000..ac49c531a --- /dev/null +++ b/doc/context/sources/general/manuals/luametafun/mozilla-svg-002.svg @@ -0,0 +1,10 @@ +<svg id="glyph651" xmlns="http://www.w3.org/2000/svg"><g fill="#42cde2"> + <path d=" + M18.06 50.947 + l-4.45 3.732.136-9.223 + a.623.623 0 0 0-.146-.408 + L11.63 42.7a.62.62 0 0 0-.873-.077 + l-8.54 7.165 + a.62.62 0 0 0-.076.874l1.93 2.3a.62.62 0 0 0 .875.074l3.948-3.313-.058 9.45c-.002.147.05.29.144.403l1.845 2.2a.62.62 0 0 0 .874.075l9.102-7.64a.62.62 0 0 0 .077-.874l-1.946-2.318a.623.623 0 0 0-.874-.075M36.03 33.53l-6.464 3.732 2.23-11.648a.812.812 0 0 0-.095-.548l-1.97-3.412a.8.8 0 0 0-1.09-.293l-12.41 7.166a.798.798 0 0 0-.292 1.09l1.928 3.34a.798.798 0 0 0 1.09.293l5.74-3.314-2.184 11.95a.794.794 0 0 0 .093.544l1.846 3.197a.797.797 0 0 0 1.09.29l13.234-7.637a.796.796 0 0 0 .292-1.09l-1.945-3.37a.8.8 0 0 0-1.09-.29M59.33 16.792l-7.794 2.837 4.686-12.316a.894.894 0 0 0 .003-.618l-1.497-4.114a.885.885 0 0 0-1.135-.53L38.63 7.5a.886.886 0 0 0-.53 1.136l1.466 4.03a.884.884 0 0 0 1.136.53l6.92-2.52-4.695 12.658a.888.888 0 0 0-.003.612l1.402 3.854a.888.888 0 0 0 1.137.53l15.953-5.806a.887.887 0 0 0 .53-1.137l-1.48-4.06a.887.887 0 0 0-1.136-.532"/> + </g> + </svg> |