Doc: documentation de la partie inc pour MetaPost
[delaunay.git] / doc / luamesh-doc.tex
1 % luamesh: compute and draw meshes with lua, luamplib and tikz
2 %
3 % Originally written by Maxime Chupin <mc@melusine.eu.org>,
4 % 2010.
5 %
6 % Distributed under the terms of the GNU free documentation licence:
7 % http://www.gnu.org/licenses/fdl.html
8 % without any invariant section or cover text.
9
10 \documentclass{lltxdoc}
11 \usepackage{tcolorbox}
12 \usepackage{xargs}
13 \usepackage{enumitem}
14 \usepackage[tikz]{bclogo}
15 \usepackage{wrapfig}
16 \title{\Verb+luamesh+: compute and draw meshes with \lualatex}
17 \author{Maxime Chupin \email{mc@melusine.eu.org}}
18 \date{\today}
19
20
21 \definecolor{darkred}{rgb}{0.8,0.1,0.1}
22
23
24 \newcommand*\commande{\noindent\hspace{-30pt}%
25 \SaveVerb[aftersave={%
26 \UseVerb{Vitem}
27 }%
28 ]{Vitem}}
29
30 \newcommand*\textme[1]{\textcolor{black}{\rmfamily\textit{#1}}}
31 \newcommand*\meta[1]{% % meta
32 \textme{\ensuremath{\langle}#1\ensuremath{\rangle}}}
33 \newcommand*\optstar{% % optional star
34 \meta{\ensuremath{*}}\xspace}
35 \DefineShortVerb{\|}
36
37 \setlength{\fboxsep}{2pt}
38 \fvset{%
39 codes={\catcode`\«\active \catcode`\×\active },
40 defineactive={\makefancyog\makefancytimes},
41 formatcom=\color{darkred},
42 frame=single
43 }
44 % rendre «...» équivalent à \meta{...}
45 {\catcode`\«\active
46 \newcommandx\makefancyog[0][addprefix=\global]{%
47 \def«##1»{\meta{##1}}}}
48 % rendre × équivalent à \optstar
49 {\catcode`\×\active
50 \newcommandx\makefancytimes[0][addprefix=\global]{%
51 \def×{\optstar{}}}}
52
53
54 \tcbuselibrary{listings,breakable}
55
56 \definecolor{vert}{rgb}{0.1,0.4,0.1}
57 \definecolor{bleu}{rgb}{0.1,0.1,0.4}
58 \lstset{
59 numberstyle=\footnotesize\color{vert},
60 keywordstyle=\ttfamily\bfseries\color{blue},
61 basicstyle=\ttfamily\footnotesize,
62 commentstyle=\itshape\color{vert},
63 stringstyle=\ttfamily,
64 showstringspaces=false,
65 language=[LaTeX]TeX,
66 breaklines=true,
67 breakindent=30pt,
68 defaultdialect=[LaTeX]TeX,
69 morekeywords={buildMeshBW,buildMeshBWinc,drawPointsMesh,
70 drawPointsMeshinc, meshAddPointBW, meshAddPointBWinc}% frame=tb
71 }
72
73 \lstdefinelanguage{lua}
74 {morekeywords={for,end,function,do,if,else,elseif,then,
75 tex.print,tex.sprint,io.read,io.open,string.find,string.explode,require},
76 morecomment=[l]{--},
77 morecomment=[s]{--[[}{]]},
78 morestring=[b]''
79 }
80
81 \newtcblisting{Exemple}{%
82 arc=0pt,outer arc=0pt,
83 colback=red!2!white,
84 colframe=red!75!black,
85 breakable,
86 boxsep=0pt,left=5pt,right=5pt,top=5pt,bottom=5pt, bottomtitle =
87 3pt, toptitle=3pt,
88 boxrule=0pt,bottomrule=0.5pt,toprule=0.5pt, toprule at break =
89 0pt, bottomrule at break = 0pt,
90 listing options={breaklines},
91 }
92
93 \newtcblisting{commandshell}{colback=black,colupper=white,colframe=black,
94 arc=0pt,
95 listing only,boxsep=0pt,listing
96 options={style=tcblatex,language=sh},
97 every listing line={\textcolor{red}{\small\ttfamily\bfseries user \$> }}}
98
99 \newtcblisting{latexcode}{
100 arc=0pt,outer arc=0pt,
101 colback=red!2!white,
102 colframe=red!75!black,
103 breakable,
104 boxsep=0pt,left=5pt,right=5pt,top=5pt,bottom=5pt, bottomtitle =
105 3pt, toptitle=3pt,
106 boxrule=0pt,bottomrule=0.5pt,toprule=0.5pt, toprule at break =
107 0pt, bottomrule at break = 0pt,
108 listing only,boxsep=0pt,listing
109 options={breaklines}
110 }
111
112
113 \newcommand\luamesh{\Verb+luamesh+\xspace}
114
115 \newenvironment{optionsenum}[1][]
116 {\begin{description}[font=\color{darkred}\ttfamily]}
117 {\end{description}}
118
119 \newenvironment{warning}{%
120 \setlength{\logowidth}{24pt}
121 \tcbset{%
122 arc=0pt,outer arc=0pt,colback=gray!10!white,colframe=gray!60!white,
123 boxsep=0pt,left=5pt,right=5pt,top=5pt,bottom=5pt, bottomtitle = 3pt, toptitle=3pt,
124 boxrule=0pt,bottomrule=0.5pt,toprule=0.5pt}
125 \medskip
126 \begin{tcolorbox}%
127 \begin{wrapfigure}[2]{L}{17pt}%
128 % \raisebox{-5pt}{
129 \vspace*{-0.55cm}
130 \bcinfo
131 % }%
132 \end{wrapfigure}
133 }%
134 {\end{tcolorbox}\medskip}
135
136 \lstset{moredelim=*[s][\color{red}\rmfamily\itshape]{<}{>}}
137 \lstset{moredelim=*[s][\color{blue}\rmfamily\itshape]{<<}{>>}}
138
139 \begin{document}
140 %% === Page de garde ===================================================
141 \thispagestyle{empty}
142 \begin{tikzpicture}[remember picture, overlay]
143 \node[below right, shift={(-4pt,4pt)}] at (current page.north west) {%
144 \includegraphics{fond.pdf}%
145 };
146 \end{tikzpicture}%
147
148 \noindent
149 \includegraphics{luamesh-title}\\
150 {\large compute and draw meshes with \lualatex}\\[1cm]
151 \parbox{0.6\textwidth}{
152 \meshAddPointBW[
153 mode=ext,step=badtriangles,
154 colorNew =green!20!red,
155 colorBack=red!10,
156 colorCircle = blue,
157 bbox = show,
158 colorBbox = black!30
159 ]
160 {meshgarde.txt}{7}
161 }\hfill
162 \parbox{0.4\textwidth}{\Large\raggedleft
163 \textbf{Contributor}\\
164 Maxime \textsc{Chupin}
165 }
166 \vfill
167 \begin{center}
168 Version 0.1, 25 novembre 2016\\
169 \url{http://melusine.eu.org/syracuse/G/delaunay/}
170 \end{center}
171 %% == Page de garde ====================================================
172 \newpage
173
174 \maketitle
175
176 \begin{abstract}
177 The package \Verb|luamesh| allows to compute and draw 2D Delaunay
178 triangulation. The algorithm is written with lua, and depending on the
179 choice of the ``engine'', the drawing is done by MetaPost (with
180 \Verb|luamplib|) or by \Verb|tikz|.
181
182 The Delaunay triangulation algorithm is the Bowyer and Watson
183 algorithm. Several macros are provided to draw the global mesh, the
184 set of points, or a particular step of the algorithm.
185 \end{abstract}
186
187 I would like to thank Jean-Michel Sarlat, who hosts the development
188 with a git project on the \Verb+melusine+ machine:
189 \begin{center}
190 \url{https://melusine.eu.org/syracuse/G/delaunay/}
191 \end{center}
192 I would also like to thank the first user, an intensive
193 \emph{test} user, and a very kind English corrector: Nicole Spillane.
194
195 \section{Installation}
196
197
198 Of course, you can just put the two files \Verb+luamesh.lua+ and
199 \Verb+luamesh.sty+ in the working directory, but this is not
200 recommended.
201
202
203 \subsection{With \TeX live and Linux or Mac OSX}
204
205 To install \luamesh with \TeX live, you have to create the local
206 \Verb+texmf+ directory in your \Verb+home+.
207
208 \begin{commandshell}
209 mkdir ~/texmf
210 \end{commandshell}
211
212 Then place the files in the correct directories. First, the
213 \Verb+luamesh.sty+ file must be in the directory:
214 \begin{center}
215 \Verb+~/texmf/tex/latex/luamesh/+
216 \end{center}
217 and secondly, the \Verb+luamesh.lua+ must be in the directory:
218 \begin{center}
219 \Verb+~/texmf/scripts/luamesh/+
220 \end{center}
221
222 Once you have done this, \luamesh can be included in your document
223 with
224 \begin{latexcode}
225 \usepackage{luamesh}
226 \end{latexcode}
227
228 \subsection{With Mik\TeX{} and Windows}
229
230 We do not know these two systems, so we refer to the
231 documentation for integrating local additions to Mik\TeX:
232 \begin{center}
233 \url{http://docs.miktex.org/manual/localadditions.html}
234 \end{center}
235
236
237 \subsection{A \lualatex package}
238
239 If you want to use this package, you must compile your document with
240 \Verb+lualatex+:
241
242 \begin{commandshell}
243 lualatex mylatexfile.tex
244 \end{commandshell}
245
246
247 \subsection{Dependencies}
248
249 This package is built upon two main existing packages to draw the
250 triangulations :
251 \begin{enumerate}
252 \item \Verb+luamplib+ to use MetaPost via the \luatex library
253 \Verb+mplib+;
254 \item and \Verb+tikz+.
255 \end{enumerate}
256 We will see how to choose between these two \emph{drawing engines}.
257
258 Moreover, the following packages are necessary:
259 \begin{enumerate}
260 \item \Verb+xkeyval+ to manage the optional arguments;
261 \item \Verb+xcolor+ to use colors (needed by \Verb+luamplib+);
262 \item \Verb+ifthen+ to help the programming with \TeX.
263 \end{enumerate}
264
265
266 \section{The Basic Macros}
267
268 Let us recall that this package provides macros to draw two
269 dimensional triangulations (or meshes).
270
271 \subsection{Draw a Complete Mesh}\label{sec:buildMesh}
272
273 \commande|\buildMeshBW[«options»]{«list of points» or «file name»}|\medskip
274
275 This macro produces the Delaunay triangulation (using the Bowyer and
276 Watson algorithm) of the given \meta{list of points}. The list of
277 points must be given in the following way :
278 \begin{center}
279 \verb+(x1,y1);(x2,y2);(x3,y3);...;(xn,yn)+
280 \end{center}
281
282 \begin{Exemple}
283 \buildMeshBW{(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}
284 \end{Exemple}
285
286 \subsubsection{The Options}
287
288 There are several options to customize the drawing.
289 \begin{optionsenum}
290 \item[mode = int (default) \textme{or} ext:] this option allows to
291 use either the previously described set of points in the argument, or
292 a file, containing, line by line (2 columns), the points. Such a
293 file looks like :
294 \begin{verbatim}
295 x1 y1
296 x2 y2
297 x3 y3
298 ...
299 xn yn
300 \end{verbatim}
301 \item[bbox = none (default) \textme{or} show:] this option allows to draw the
302 added points to form a \emph{bounding box}\footnote{The bounding
303 box is defined by four points place at 15\% around the box
304 defined by $(x_{\min},y_{\min})$, $(x_{\min},y_{\max})$,
305 $(x_{\max},y_{\max})$, and $(x_{\min},y_{\max})$. It is used by
306 the algorithm and will be computed in any case.} and the corresponding
307 triangulation. By default, these triangles are removed at the end of
308 the algorithm.
309 \item[color = \meta{value} (default: black):] The color of the
310 drawing.
311 \item[colorBbox = \meta{value} (default: black):] The color of the
312 drawing for the elements (points and triangles) belonging to the
313 bounding box.
314 \item[print = none (default) \textme{or} points:] To label the vertices of the
315 triangulation. This also adds a \emph{dot} at each vertex.
316 \item[meshpoint = \meta{value} (default: P):] The letter(s) used to
317 label the vertices of the triangulation. It is included in the math
318 mode delimiters \Verb+$...$+. The bounding box points are labeled
319 with numbers 1 to 4 and with a star exponent.
320 \item[tikz (boolean, default:false):] By default, this boolean is set
321 to \Verb+false+, and MetaPost (with \Verb+luamplib+) is used to draw
322 the picture. With this option, \Verb+tikz+ becomes the \textit{drawing
323 engine}.
324 \item[scale = \meta{value} (default: 1cm):] The scale option defines
325 the scale at which the picture is drawn (the same for both
326 axes). It must contain the unit of length (cm,
327 pt, etc.).
328 \end{optionsenum}
329
330 To illustrate the options, let us show you an example. We consider a
331 file \Verb+mesh.txt+:
332 \begin{verbatim}
333 0.3 0.3
334 1.5 1
335 4 0
336 4.5 2.5
337 1.81 2.14
338 2.5 0.5
339 2.8 1.5
340 \end{verbatim}
341 \begin{Exemple}
342 \buildMeshBW[%
343 tikz,
344 mode = ext,
345 bbox = show,
346 color = red,
347 colorBbox = blue!30,
348 print = points,
349 meshpoint = x,
350 scale = 1.3cm,
351 ]{mesh.txt}
352 \end{Exemple}
353
354 \begin{warning}
355 The drawing engine is not very relevant here, but it is useful to
356 understand how the drawing is made. However, the engine will be
357 relevant to
358 the so called \emph{inc} macros (section~\ref{sec:inc}), for adding
359 code before and after the one generated by
360 \luamesh.
361 \end{warning}
362
363 \subsection{Draw the Set of Points}
364
365 \commande|\drawPointsMesh[«options»]{«list of points» or «file name»}|\medskip
366
367 With the \Verb+\drawPointsMesh+, we plot the set of (user chosen) points from
368 which the Bowyer and Watson algorithm computes the triangulation.
369
370 The use of this macro is quite similar to
371 \Verb+\buildMeshBW+. Here is an example of the basic uses.
372 \begin{Exemple}
373 \drawPointsMesh{(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}
374 \end{Exemple}
375
376
377 \subsubsection{The Options}
378
379 There are several options (exactly the same as for the
380 \Verb+\buildMeshBW+) to customize the drawing.
381 \begin{optionsenum}
382 \item[mode = int (default) \textme{or} ext:] this option allows to
383 use either the previously described set of points as the argument, or
384 a file, containing, line by line (2 columns), the points. Such a
385 file looks like :
386 \begin{verbatim}
387 x1 y1
388 x2 y2
389 x3 y3
390 ...
391 xn yn
392 \end{verbatim}
393 \item[bbox = none (default) \textme{or} show:] this option allows to draw the
394 added points to form a \emph{bounding box} and the corresponding
395 triangulation. By default, these triangles are removed at the end of
396 the algorithm. \emph{Here, because we plot only the vertices of the
397 mesh, there are no triangles, only dots.}
398 \item[color = \meta{value} (default: black):] The color of the
399 drawing.
400 \item[colorBbox = \meta{value} (default: black):] The color of the
401 drawing for the elements (points and triangles) belonging to the
402 bounding box.
403 \item[print = none (default) \textme{or} points:] To label the vertices of the
404 triangulation. This also adds a \emph{dot} at each vertex. Without
405 label, there is still the dot.
406 \item[meshpoint = \meta{value} (default: P):] The letter(s) used to
407 label the vertices of the triangulation. It is included in the math
408 mode delimiters \Verb+$...$+. The bounding box points are labeled
409 with numbers 1 to 4 and with a star exponent.
410 \item[tikz (boolean, default:false):] By default, this boolean is set
411 to \Verb+false+, and MetaPost (with \Verb+luamplib+) is used to draw
412 the picture. With this option, \Verb+tikz+ becomes the \textit{drawing
413 engine}.
414 \item[scale = \meta{value} (default: 1cm):] The scale option defines
415 the scale at which the picture is drawn (the same for both
416 axes). It must contain the unit of length (cm,
417 pt, etc.).
418 \end{optionsenum}
419 With the same external mesh point file presented in
420 section~\ref{sec:buildMesh}, we illustrate the different options.
421
422 \begin{Exemple}
423 \drawPointsMesh[%
424 tikz,
425 mode = ext,
426 bbox = show,
427 color = blue,
428 colorBbox = red,
429 print = points,
430 meshpoint = y,
431 scale = 1.3cm,
432 ]{mesh.txt}
433 \end{Exemple}
434
435
436 \subsection{Draw a Step of the Bowyer and Watson Algorithm}
437
438 \commande|\meshAddPointBW[«options»]{«list of points» or «file name»}{«point» or «number of line»}|\medskip
439
440 This command allows to plot the steps within the addition of a
441 point in a Delaunay triangulation, by the Bowyer and Watson
442 algorithm.
443
444 This macro produces the Delaunay triangulation (using the Bowyer and
445 Watson algorithm) of the given \meta{list of points} and shows a step
446 of the algorithm when the \meta{point} is added. The list of
447 points must be given in the following way:
448 \begin{center}
449 \verb+(x1,y1);(x2,y2);(x3,y3);...;(xn,yn)+
450 \end{center}
451 and the point is of the form \verb+(x,y)+. The \meta{file name}
452 and \meta{number of line} will be explained in the option
453 description.
454
455 One can use the macro as fallows:
456 \begin{Exemple}
457 \meshAddPointBW[step=badtriangles]{(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}{(2.2,1.8)}
458 \meshAddPointBW[step=cavity]{(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}{(2.2,1.8)}
459 \meshAddPointBW[step=newtriangles]{(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}{(2.2,1.8)}
460 \end{Exemple}
461 The default value for \Verb+step+ is
462 \Verb+badtriangles+. Consequently, the first
463 line is equivalent to
464 \begin{latexcode}
465 \meshAddPointBW{(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}{(2.2,1.8)}
466 \end{latexcode}
467
468 \subsubsection{The Options}
469
470 There are several options (some of them are the same as for
471 \Verb+\buildMeshBW+) to customize the drawing.
472 \begin{optionsenum}
473 \item[mode = int (default) \textme{or} ext:] this option allows to
474 use either the previously described set of point in the first
475 argument, or
476 a file containing, line by line (2 columns), the points. Such a
477 file looks like :
478 \begin{verbatim}
479 x1 y1
480 x2 y2
481 x3 y3
482 ...
483 xn yn
484 \end{verbatim}
485 For the second argument of the macro, if we are in the
486 \Verb+mode = ext+, the argument must be the \emph{line number} of the file
487 corresponding to the point we want to add. The algorithm will stop the
488 line before to build the initial triangulation for which it will add
489 the point corresponding to the line. The subsequent lines in the file are
490 ignored.
491 \item[bbox = none (default) \textme{or} show:] this option allows to draw the
492 added points to form a \emph{bounding box} and the corresponding
493 triangulation. By default, these triangles are removed at the end of
494 the algorithm.
495 \item[color = \meta{value} (default: black):] The color of the
496 drawing.
497 \item[colorBbox = \meta{value} (default: black):] The color of the
498 drawing for the elements (points and triangles) belonging to the
499 bounding box.
500 \item[colorNew = \meta{value} (default: red):] The color of the
501 drawing of the ``new'' elements which are the point to add, the
502 polygon of the cavity, and the new triangles.
503 \item[colorBack = \meta{value} (default: black!20):] The color for the
504 filling of the region concerned by the addition of the new point.
505 \item[colorCircle = \meta{value} (default: green):] The color for
506 the circumcircle of the triangles containing the point to add.
507 \item[meshpoint = \meta{value} (default: P):] The letter(s) used to
508 label the vertices of the triangulation. It is included in the math
509 mode delimiters \Verb+$...$+. The bounding box points are labeled
510 with numbers 1 to 4 and with a star exponent.
511 \item[step = badtriangles (default) \textme{or} cavity \textme{or}
512 newtriangles:] To choose the step we want to draw, corresponding to
513 the steps of the Bowyer and Watson algorithm.
514 \item[newpoint = \meta{value} (default: P):] The letter(s) used to
515 label the new point of the triangulation. It is include in the math
516 mode delimiters \Verb+$...$+.
517 \item[tikz (boolean, default:false):] By default, this boolean is set
518 to \Verb+false+, and MetaPost (with \Verb+luamplib+) is used to draw
519 the picture. With this option, \Verb+tikz+ is the \textit{drawing
520 engine}.
521 \item[scale = \meta{value} (default: 1cm):] The scale option defines
522 the scale at which the picture is draw (the same for the two
523 axis). It must contain the unit of length (cm,
524 pt, etc.).
525 \end{optionsenum}
526
527 Here is an example of customizing the drawing. First, recall that
528 the external file \Verb+mesh.txt+ is:
529 \begin{verbatim}
530 0.3 0.3
531 1.5 1
532 4 0
533 4.5 2.5
534 1.81 2.14
535 2.5 0.5
536 2.8 1.5
537 \end{verbatim}
538 We draw the addition of the 6th point. The 7th line will be ignored.
539 \begin{Exemple}
540 \meshAddPointBW[
541 tikz,
542 mode = ext,
543 color = blue!70,
544 meshpoint = \alpha,
545 newpoint = y,
546 colorBack=red!10,
547 colorNew = green!50!red,
548 colorCircle = blue,
549 colorBbox = black!20,
550 bbox = show,
551 scale=1.4cm,
552 step=badtriangles]
553 {mesh.txt}{6}
554 \end{Exemple}
555
556 \section{The \emph{inc} Macros}\label{sec:inc}
557
558 The three macros presented in the above sections have complementary
559 macros, with the suffix \Verb+inc+ that allow the user to add code
560 (MetaPost or \Verb+tikz+, depending of the drawing engine) before and
561 after the code generated by \luamesh.
562
563 The three macros are:
564
565 \commande|\buildMeshBWinc[«options»]{«list of points» or «file name»}{«code before»}{«code after»}|\medskip
566
567 \commande|\drawPointsMeshinc[«options»]{«list of points» or «file name»}{«code before»}{«code after»}|\medskip
568
569 \commande|\meshAddPointBWinc[«options»]{«list of points» or «file name»}%|
570
571 \commande| {«point» or «number of line»}{«code before»}{«code after»}|\medskip
572
573 \subsection{With MetaPost}
574
575 We consider the case where the drawing engine is MetaPost (through the
576 \Verb+luamplib+ package).
577
578 We describe the feature taking one macro in example but the mechanism
579 and the possibilities are exactly the same for all the macros.
580
581 When we use the MetaPost drawing engine, the macros previously
582 described produced a code of the form
583 \begin{latexcode}
584 \begin{luamplib}
585 u:=<scale>;
586 beginfig(0);
587 <code for the drawing>
588 endfig;
589 \end{luamplib}
590 \end{latexcode}
591
592 Then, the arguments \meta{code before} and \meta{code after} are
593 inserted as follows:
594 \begin{latexcode}
595 \begin{luamplib}
596 u:=<scale>;
597 <<code before>>
598 <code for the drawing>
599 <<code after>>
600 \end{luamplib}
601 \end{latexcode}
602 \begin{warning}
603 With the \emph{inc} macros, the user has to add the \Verb+beginfig();+
604 and \Verb+endfig;+ commands to produce a picture. Indeed, this allows
605 to use the \Verb+\everymplib+ command from the \Verb+\luamplib+ package.
606 \end{warning}
607
608 \subsubsection{The \LaTeX{} Colors Inside the MetaPost Code}
609
610 The configurable colors
611 of the \LaTeX{} macro are accessible inside the MetaPost code. For
612 \Verb+\buildMeshBWinc+ and \Verb+\drawPointsMeshinc+, we have
613 \Verb+\luameshmpcolor+,
614 and \Verb+\luameshmpcolorBbox+.
615 For the macro \Verb+\meshAddPointBWinc+ we have three additional
616 colors : \Verb+\luameshmpcolorBack+, \Verb+\luameshmpcolorNew+, and
617 \Verb+\luameshmpcolorCircle+. Of course, we can define MetoPost
618 colors as well. Finally, the \Verb+luamplib+ mechanism of
619 \Verb+\mpcolor+ is also available.
620
621 \subsubsection{The Mesh Points with MetaPost}
622
623 At the beginning of the automatically generated code, a list of
624 MetaPost \Verb+pair+s are defined corresponding to all the vertices of
625 the mesh (when the option \Verb+bbox=show+, the last 4 points are the
626 \emph{bounding box points}). The points are available with the
627 \Verb+MeshPoints[]+ table of variables. The \Verb+MeshPoints[i]+ are
628 defined using the unit length \Verb+u+.
629
630 \subsubsection{Examples}
631
632 Here is three examples for the different macros.
633 \begin{Exemple}
634 \drawPointsMeshinc[
635 color = blue!50,
636 print = points,
637 meshpoint = x,
638 scale=0.8cm,
639 ]{(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}%
640 {% code before
641 beginfig(0);
642 }%
643 {% code after
644 label(btex Mesh $\mathbb{T}$ etex, (0,2u)) withcolor \luameshmpcolor;
645 endfig;
646 }
647 \buildMeshBWinc[%
648 bbox = show,
649 color = red,
650 colorBbox = blue!30,
651 print = points,
652 meshpoint = x,
653 scale=0.8cm
654 ]{(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5);(2.8,1.5)}%
655 {% code before
656 beginfig(0);
657 }
658 {% code after
659 drawdblarrow MeshPoints[3] -- MeshPoints[9] withpen pencircle scaled 1pt
660 withcolor (0.3,0.7,0.2);
661 endfig;
662 }
663 \meshAddPointBWinc[
664 meshpoint = \alpha,
665 newpoint = y,
666 colorBack=red!10,
667 colorNew = green!50!red,
668 colorCircle = blue,
669 colorBbox = black!20,
670 bbox = show,
671 scale=0.8cm,
672 step=badtriangles]
673 {(0.3,0.3);(1.5,1);(4,0);(4.5,2.5);(1.81,2.14);(2.5,0.5)}{(2.8,1.5)}%
674 {%code before
675 picture drawing;
676 drawing := image(
677 }{%code after
678 );
679 beginfig(0);
680 fill MeshPoints[7]--MeshPoints[8]--MeshPoints[9]--MeshPoints[10]--cycle
681 withcolor \mpcolor{blue!10};
682 draw drawing;
683 endfig;
684 }
685 \end{Exemple}
686 \begin{warning}
687 The variables \Verb+MeshPoints[]+ are not defined for the argument
688 corresponding to the code to place before the code generated by
689 \luamesh. Hence, to use such variables, we have to define a
690 \Verb+picture+ as shown in the third example above.
691 \end{warning}
692
693
694 \subsection{With TikZ}
695
696
697
698 \section{Gallery of Examples}
699
700 \end{document}
701
702
703
704 %%% Local Variables:
705 %%% flyspell-mode: 1
706 %%% ispell-local-dictionary: "american"
707 %%% End:

Licence Creative Commons Les fichiers de Syracuse sont mis à disposition (sauf mention contraire) selon les termes de la
Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Partage dans les Mêmes Conditions 4.0 International.