Doc: documentation de la partie inc pour MetaPost
authorMaxime Chupin (Ceremade) <chupin@ceremade.dauphine.fr>
Mon, 28 Nov 2016 13:08:48 +0000 (14:08 +0100)
committerMaxime Chupin (Ceremade) <chupin@ceremade.dauphine.fr>
Mon, 28 Nov 2016 13:08:48 +0000 (14:08 +0100)
doc/luamesh-doc.listing
doc/luamesh-doc.pdf
doc/luamesh-doc.tex
index.md
luamesh.lua
luamesh.sty

index cf8777e..805f630 100644 (file)
@@ -1,14 +1,51 @@
-  \meshAddPointBW[
-  tikz,
-  mode = ext,
-  color = blue!70,
-  meshpoint = \alpha,
-  newpoint = y,
-  colorBack=red!10,
-  colorNew = green!50!red,
-  colorCircle = blue,
-  colorBbox = black!20,
-  bbox = show,
-  scale=1.4cm,
-  step=badtriangles]
-  {mesh.txt}{6}
+\drawPointsMeshinc[
+color = blue!50,
+print = points,
+meshpoint = x,
+scale=0.8cm,
+]{(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)}%
+{% code before
+  beginfig(0);
+}%
+{% code after
+  label(btex Mesh $\mathbb{T}$ etex, (0,2u)) withcolor \luameshmpcolor;
+  endfig;
+}
+\buildMeshBWinc[%
+bbox = show,
+color = red,
+colorBbox = blue!30,
+print = points,
+meshpoint = x,
+scale=0.8cm
+]{(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)}%
+{% code before
+  beginfig(0);
+}
+{% code after
+  drawdblarrow MeshPoints[3] -- MeshPoints[9] withpen pencircle scaled 1pt
+  withcolor (0.3,0.7,0.2);
+  endfig;
+}
+\meshAddPointBWinc[
+meshpoint = \alpha,
+newpoint = y,
+colorBack=red!10,
+colorNew = green!50!red,
+colorCircle = blue,
+colorBbox = black!20,
+bbox = show,
+scale=0.8cm,
+step=badtriangles]
+{(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)}%
+{%code before
+  picture drawing;
+  drawing := image(
+}{%code after
+  );
+  beginfig(0);
+  fill MeshPoints[7]--MeshPoints[8]--MeshPoints[9]--MeshPoints[10]--cycle
+  withcolor \mpcolor{blue!10};
+  draw drawing;
+  endfig;
+}
index e5ad52d..4278d15 100644 (file)
Binary files a/doc/luamesh-doc.pdf and b/doc/luamesh-doc.pdf differ
index 57ba342..9330b5e 100644 (file)
   }%
   {\end{tcolorbox}\medskip}
 
+\lstset{moredelim=*[s][\color{red}\rmfamily\itshape]{<}{>}}
+\lstset{moredelim=*[s][\color{blue}\rmfamily\itshape]{<<}{>>}}
 
 \begin{document}
 %% === Page de garde ===================================================
@@ -580,14 +582,119 @@ When we use the MetaPost drawing engine, the macros previously
 described produced a code of the form
 \begin{latexcode}
 \begin{luamplib}
+  u:=<scale>;
+  beginfig(0);
+  <code for the drawing>
+  endfig;
+\end{luamplib}
+\end{latexcode}
 
+Then, the arguments \meta{code before} and \meta{code after} are
+inserted as follows:
+\begin{latexcode}
+\begin{luamplib}
+  u:=<scale>;
+  <<code before>>
+  <code for the drawing>
+  <<code after>>
 \end{luamplib}
 \end{latexcode}
+\begin{warning}
+With the \emph{inc} macros, the user has to add the \Verb+beginfig();+
+and \Verb+endfig;+ commands to produce a picture. Indeed, this allows
+to use the \Verb+\everymplib+ command from the \Verb+\luamplib+ package.
+\end{warning}
 
+\subsubsection{The \LaTeX{} Colors Inside the MetaPost Code}
+
+The configurable colors
+of the \LaTeX{} macro are accessible inside the MetaPost code. For
+\Verb+\buildMeshBWinc+ and \Verb+\drawPointsMeshinc+, we have
+\Verb+\luameshmpcolor+,
+and \Verb+\luameshmpcolorBbox+.
+For the macro \Verb+\meshAddPointBWinc+ we have three additional
+colors : \Verb+\luameshmpcolorBack+, \Verb+\luameshmpcolorNew+, and
+\Verb+\luameshmpcolorCircle+. Of course, we can define MetoPost
+colors as well. Finally, the \Verb+luamplib+ mechanism of
+\Verb+\mpcolor+ is also available.
+
+\subsubsection{The Mesh Points with MetaPost}
+
+At the beginning of the automatically generated code, a list of
+MetaPost \Verb+pair+s are defined corresponding to all the vertices of
+the mesh (when the option \Verb+bbox=show+, the last 4 points are the
+\emph{bounding box points}). The points are available with the
+\Verb+MeshPoints[]+ table of variables. The \Verb+MeshPoints[i]+ are
+defined using the unit length \Verb+u+.
+
+\subsubsection{Examples}
+
+Here is three examples for the different macros.
+\begin{Exemple}
+\drawPointsMeshinc[
+color = blue!50,
+print = points,
+meshpoint = x,
+scale=0.8cm,
+]{(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)}%
+{% code before
+  beginfig(0);
+}%
+{% code after
+  label(btex Mesh $\mathbb{T}$ etex, (0,2u)) withcolor \luameshmpcolor;
+  endfig;
+}
+\buildMeshBWinc[%
+bbox = show,
+color = red,
+colorBbox = blue!30,
+print = points,
+meshpoint = x,
+scale=0.8cm
+]{(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)}%
+{% code before
+  beginfig(0);
+}
+{% code after
+  drawdblarrow MeshPoints[3] -- MeshPoints[9] withpen pencircle scaled 1pt
+  withcolor (0.3,0.7,0.2);
+  endfig;
+}
+\meshAddPointBWinc[
+meshpoint = \alpha,
+newpoint = y,
+colorBack=red!10,
+colorNew = green!50!red,
+colorCircle = blue,
+colorBbox = black!20,
+bbox = show,
+scale=0.8cm,
+step=badtriangles]
+{(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)}%
+{%code before
+  picture drawing;
+  drawing := image(
+}{%code after
+  );
+  beginfig(0);
+  fill MeshPoints[7]--MeshPoints[8]--MeshPoints[9]--MeshPoints[10]--cycle
+  withcolor \mpcolor{blue!10};
+  draw drawing;
+  endfig;
+}
+\end{Exemple}
+\begin{warning}
+  The variables \Verb+MeshPoints[]+ are not defined for the argument
+  corresponding to the code to place before the code generated by
+  \luamesh. Hence, to use such variables, we have to define a
+  \Verb+picture+ as shown in the third example above.
+\end{warning}
 
 
 \subsection{With TikZ}
 
+
+
 \section{Gallery of Examples}
 
 \end{document}
index f2a9981..fb8af12 100644 (file)
--- a/index.md
+++ b/index.md
@@ -17,13 +17,16 @@ working properly yet. There is no documentation (but there will be).
 Every feedback will be appreciated.
 </div>
 
+## Documentation
+
+A PDF documentation is available in the `doc` directory.
+
 ## TODO list
 
-* **Update `tikz` functions**.
 * Reader for gmesh `msh` file to plot meshes produced by this
   software.
 * Macro to generate a meshed rectangle.
 * Macro to generate a meshed circle.
 * Macro that, given a border defined by a set of points, adds points
   inside to generate the mesh.
-* Other 2D algorithms (divide and conquer)
+* Other 2D algorithms (divide and conquer, etc.)
index 83c2c25..e23d7a0 100644 (file)
@@ -285,7 +285,7 @@ function traceMeshMP(listPoints, triangulation,points)
    output = "";
    output = output .. " pair MeshPoints[];"
    for i=1,#listPoints do
-      output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");"
+      output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ")*u;"
    end
 
    for i=1,#triangulation do
@@ -355,7 +355,7 @@ function tracePointsMP(listPoints,points)
    output = "";
    output = output .. " pair MeshPoints[];"
    for i=1,#listPoints do
-      output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");"
+      output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ")*u;"
    end
    if(points=="points") then
       j=1
@@ -423,7 +423,7 @@ function printPointsMPinc(chaine,beginning, ending, mode,points,bbox,scale)
       listPoints = buildBoundingBox(listPoints)
    end
    output = tracePointsMP(listPoints,points)
-   output = "\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
+   output = "\\leavevmode\\begin{mplibcode}u:="..scale..";"..beginning .. output .. ending .. "\\end{mplibcode}"
    tex.sprint(output)
 end
 
@@ -637,7 +637,7 @@ function TeXaddOnePointMPBW(listPoints,P,step,bbox)
    triangulation = BowyerWatson(listPoints,bbox)
    badTriangles = buildBadTriangles(P,triangulation)
    for i=1,#listPoints do
-      output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ");"
+      output = output .. "MeshPoints[".. i .. "] = (" .. listPoints[i].x .. "," .. listPoints[i].y .. ")*u;"
    end
    if(step == "badT") then
       -- draw all triangle
index 5110cb3..3c6569c 100644 (file)
@@ -33,8 +33,8 @@
 \definecolor{TeXCluaMeshBackTikZ}{rgb}{0.99,0.85,0.85}
 % default color for circoncircle
 \definecolor{TeXCluaMeshCircleTikZ}{rgb}{0.1,0.6,0.1}
-
-
+%%
+%
 %%%%%%%%%%%%%%%% the buildMesh command
 %% the user can write code (tikz or MP)
 %% before and after the generated code
@@ -87,8 +87,8 @@
     buildMeshTikZBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bmi@mode","\luameshval@bmi@print","\luameshval@bmi@bbox","\luameshval@bmi@scale","\luameshval@bmi@color","\luameshval@bmi@colorbbox")%
   }%
   \else % we are using MP
-  \mplibcolor{\luameshmpcolor}{\luameshval@bmi@color}
-  \mplibcolor{\luameshmpcolorBbox}{\luameshval@bmi@colorbbox}
+  \mplibcolor{\luameshmpcolor}{\luameshval@bmi@color}%
+  \mplibcolor{\luameshmpcolorBbox}{\luameshval@bmi@colorbbox}%
   \directlua{%
     buildMeshMPBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bmi@mode","\luameshval@bmi@print","\luameshval@bmi@bbox","\luameshval@bmi@scale")%
   }%
     buildMeshTikZBW("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale","\luameshval@bm@color","\luameshval@bm@colorbbox")%
   }%
   \else % we are using MP
-  \mplibcolor{\luameshmpcolor}{\luameshval@bm@color}
-  \mplibcolor{\luameshmpcolorBbox}{\luameshval@bm@colorbbox}
+  \mplibcolor{\luameshmpcolor}{\luameshval@bm@color}%
+  \mplibcolor{\luameshmpcolorBbox}{\luameshval@bm@colorbbox}%
   \directlua{%
     buildMeshMPBW("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale")%
   }%
     printPointsTikZ("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale","\luameshval@tp@color","\luameshval@tp@colorbbox")%
   }%
   \else % we are using MP
-  \mplibcolor{\luameshmpcolor}{\luameshval@tp@color}
-  \mplibcolor{\luameshmpcolorBbox}{\luameshval@tp@colorbbox}
+  \mplibcolor{\luameshmpcolor}{\luameshval@tp@color}%
+  \mplibcolor{\luameshmpcolorBbox}{\luameshval@tp@colorbbox}%
   \directlua{%
     printPointsMP("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale")%
   }%
   \def\MeshPoint{\luameshval@tpi@meshpoint}%
   \ifKV@drawPointsInc@tikz% if we are using tikz
   \directlua{%
-    buildMeshTikZ("#2","\luameshval@tpi@mode","\luameshval@tpi@print","\luameshval@tpi@bbox","full","\luameshval@tpi@sc%ale","\luameshval@tpi@color")%
+    buildMeshTikZ("#2","\luameshval@tpi@mode","\luameshval@tpi@print","\luameshval@tpi@bbox","full","\luameshval@tpi@scale","\luameshval@tpi@color")%
   }%
   \else % we are using MP
-  \mplibcolor{\luameshmpcolor}{\luameshval@tpi@color}
-  \mplibcolor{\luameshmpcolorBbox}{\luameshval@tpi@colorbbox}
+  \mplibcolor{\luameshmpcolor}{\luameshval@tpi@color}%
+  \mplibcolor{\luameshmpcolorBbox}{\luameshval@tpi@colorbbox}%
   \directlua{%
     printPointsMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@tpi@mode","\luameshval@tpi@print","\luameshval@tpi@bbox","\luameshval@tpi@scale")%
   }%

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.