summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/luametafun/luametafun-arrow.tex
blob: 72c9528e8b3d7e21dc91ca47b22bc9a6a8bcdee8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
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