luametafun-placeholder.tex /size: 3941 b    last modification: 2021-10-28 13:50
1% language=us runpath=texruns:manuals/luametafun
2
3\environment luametafun-style
4
5\startcomponent luametafun-placeholder
6
7\startchapter[title={Placeholder}]
8
9Placeholders are an old \CONTEXT\ features and have been around since we started using
10\METAPOST. They are used as dummy figure, just in case one is not (yet) present. They
11are normally activated by loading a \METAFUN\ library:
12
13\starttyping[option=TEX]
14\useMPLibrary[dum]
15\stoptyping
16
17Just because it could be done conveniently, placeholders are now defined at the
18\METAPOST\ end instead of as useable \METAPOST\ graphic at the \TEX\ end. The
19variants and options are demonstrated using side floats.
20
21\startbuffer[1]
22\startMPcode
23    lmt_placeholder [
24        width       = 4cm,
25        height      = 3cm,
26        color       = "red",
27        alternative = "circle".
28    ] ;
29\stopMPcode
30\stopbuffer
31
32\startplacefigure[location=left]
33    \getbuffer[1]
34\stopplacefigure
35
36\typebuffer[1][option=TEX]
37
38In addition to the traditional random circle we now also provide rectangles
39and triangles. Maybe some day more variants will show up.
40
41\startbuffer[2]
42\startMPcode
43    lmt_placeholder [
44        width       = 4cm,
45        height      = 3cm,
46        color       = "green",
47        alternative = "square".
48    ] ;
49\stopMPcode
50\stopbuffer
51
52\startplacefigure[location=left]
53    \getbuffer[2]
54\stopplacefigure
55
56\typebuffer[2][option=TEX]
57
58Here we set the colors but in the image placeholder mechanism we cycle through
59colors automatically. Here we use primary, rather dark, colors.
60
61\startbuffer[3]
62\startMPcode
63    lmt_placeholder [
64        width       = 4cm,
65        height      = 3cm,
66        color       = "blue",
67        alternative = "triangle".
68    ] ;
69\stopMPcode
70\stopbuffer
71
72\startplacefigure[location=left]
73    \getbuffer[3]
74\stopplacefigure
75
76\typebuffer[3][option=TEX]
77
78\startbuffer[4a]
79\startMPcode
80    lmt_placeholder [
81        width       = 4cm,
82        height      = 3cm,
83        color       = "yellow",
84        alternative = "circle".
85        reduction   = 0,
86    ] ;
87\stopMPcode
88\stopbuffer
89
90\startbuffer[4b]
91\startMPcode
92    lmt_placeholder [
93        width       = 4cm,
94        height      = 3cm,
95        color       = "yellow",
96        alternative = "circle".
97        reduction   = 0.25,
98    ] ;
99\stopMPcode
100\stopbuffer
101
102\startbuffer[4c]
103\startMPcode
104    lmt_placeholder [
105        width       = 4cm,
106        height      = 3cm,
107        color       = "yellow",
108        alternative = "circle".
109        reduction   = 0.50,
110    ] ;
111\stopMPcode
112\stopbuffer
113
114\startbuffer[4d]
115\startMPcode
116    lmt_placeholder [
117        width       = 4cm,
118        height      = 3cm,
119        color       = "yellow",
120        alternative = "circle".
121        reduction   = 0.75,
122    ] ;
123\stopMPcode
124\stopbuffer
125
126If you want less dark colors, the \type {reduction} parameter can be used to
127interpolate between the given color and white; its value is therefore a value
128between zero (default) and 1 (rather pointless as it produces white).
129
130\startplacefigure[location=left]
131    \startcombination[2*2]
132        {\getbuffer[4a]} {0}
133        {\getbuffer[4b]} {0.25}
134        {\getbuffer[4c]} {0.50}
135        {\getbuffer[4d]} {0.75}
136    \stopcombination
137\stopplacefigure
138
139We demonstrate this with four variants, all circles. Of course you can also use
140lighter colors, but this option was needed for the image placeholders anyway.
141
142\typebuffer[4b][option=TEX]
143
144\flushsidefloats
145
146There are only a few possible parameters. As you can see, proper dimensions need
147to be given because the defaults are pretty small.
148
149\starttabulate[|T|T|T|p|]
150\FL
151\BC name        \BC type    \BC default    \BC comment \NC \NR
152\ML
153\NC color       \NC string  \NC red    \NC \NC \NR
154\NC width       \NC numeric \NC 1      \NC \NC \NR
155\NC height      \NC numeric \NC 1      \NC \NC \NR
156\NC reduction   \NC numeric \NC 0      \NC \NC \NR
157\NC alternative \NC string  \NC circle \NC \NC \NR
158\LL
159\stoptabulate
160
161\stopchapter
162
163\stopcomponent
164