Fonctions (TikZ et MP) inc pour Voronoi
[delaunay.git] / luamesh.sty
index 5110cb3..14bc1b1 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")%
   }%
   %
   \fi%
 }%
+%%%%%%%%%%%%%%%% the buildVoronoi command
+%% the user can write code (tikz or MP)
+%% before and after the generated code
+\define@boolkey{buildVoronoiInc}{tikz}[true]{}%
+%% show the bounding box for delaunay
+\define@choicekey*{buildVoronoiInc}{bbox}[\val\nr]{none, show}{%
+  \ifcase\nr\relax%
+  \def\luameshval@bvi@bbox{none}%
+  \or%
+  \def\luameshval@bvi@bbox{bbox}%
+  \fi%
+}%
+%% the scale
+\define@key{buildVoronoiInc}{scale}[1cm]{\def\luameshval@bvi@scale{#1}}%
+%% print ponits ?
+\define@choicekey*{buildVoronoiInc}{print}[\val\nr]{none, points}{%
+  \ifcase\nr\relax%
+  \def\luameshval@bvi@print{none}%
+  \or%
+  \def\luameshval@bvi@print{points}%
+  \fi%
+}%
+%% the name of the point
+\define@key{buildVoronoiInc}{meshpoint}[P]{\def\luameshval@bvi@meshpoint{#1}}%
+%% the name of the circum point
+\define@key{buildVoronoiInc}{circumpoint}[P]{\def\luameshval@bvi@circumpoint{#1}}%
+%% the mode for reading the points
+\define@choicekey*{buildVoronoiInc}{mode}[\val\nr]{int, ext}{%
+  \ifcase\nr\relax%
+  \def\luameshval@bvi@mode{int}%
+  \or%
+  \def\luameshval@bvi@mode{ext}%
+  \fi%
+}%
+%% the mode for reading the points
+\define@choicekey*{buildVoronoiInc}{delaunay}[\val\nr]{none, show}{%
+  \ifcase\nr\relax%
+  \def\luameshval@bvi@delaunay{none}%
+  \or%
+  \def\luameshval@bvi@delaunay{show}%
+  \fi%
+}%
+%% the name of the color of drawing
+\define@key{buildVoronoiInc}{color}[black]{\def\luameshval@bvi@color{#1}}%
+%% the name of the color of drawing Voronoi
+\define@key{buildVoronoiInc}{colorVoronoi}[red]{\def\luameshval@bvi@colorvoronoi{#1}}%
+%% the name of the color of drawing the bbox
+\define@key{buildVoronoiInc}{colorBbox}[black]{\def\luameshval@bvi@colorbbox{#1}}%
+%
+\presetkeys{buildVoronoiInc}{tikz=false,bbox=none,scale, meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none}{}%
+%
+\newcommand*{\buildVoronoiBWinc}[4][]{%
+  % #1 : optionnal arguments
+  % #2 : the string containing the list of points
+  % (x1,y1);(x2,y2);... or the name file containing the points
+  % #3 : the code to place before the generated one
+  % #4 : the code to place after the generated one
+  \setkeys{buildVoronoiInc}{#1} %
+  \def\MeshPoint{\luameshval@bvi@meshpoint}%
+  \def\CircumPoint{\luameshval@bvi@circumpoint}%
+  \ifKV@buildVoronoiInc@tikz% if we are using tikz
+  \directlua{%
+    buildVoronoiTikZBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bvi@mode","\luameshval@bvi@print","\luameshval@bvi@bbox","\luameshval@bvi@scale","\luameshval@bvi@delaunay","\luameshval@bvi@color","\luameshval@bvi@colorbbox","\luameshval@bvi@colorvoronoi")%
+  }%
+  \else % we are using MP
+  \mplibcolor{\luameshmpcolor}{\luameshval@bvi@color}%
+  \mplibcolor{\luameshmpcolorBbox}{\luameshval@bvi@colorbbox}%
+  \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@bvi@colorvoronoi}%
+  \directlua{%
+    buildVoronoiMPBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bvi@mode","\luameshval@bvi@print","\luameshval@bvi@bbox","\luameshval@bvi@scale","\luameshval@bvi@delaunay")%
+  }%
+  %
+  \fi%
+}%
+%
+%%%%%%%%%%%%%%%% the buildVoronoiBW command
+%% the code is complete and we don't have any callbacks
+\define@boolkey{buildVoronoi}{tikz}[true]{}%
+%% show the bounding box for delaunay
+\define@choicekey*{buildVoronoi}{bbox}[\val\nr]{none, show}{%
+  \ifcase\nr\relax%
+  \def\luameshval@bv@bbox{none}%
+  \or%
+  \def\luameshval@bv@bbox{bbox}%
+  \fi%
+}%
+%% the scale
+\define@key{buildVoronoi}{scale}[1cm]{\def\luameshval@bv@scale{#1}}%
+%% print points
+\define@choicekey*{buildVoronoi}{print}[\val\nr]{none, points}{%
+  \ifcase\nr\relax%
+  \def\luameshval@bv@print{none}%
+  \or%
+  \def\luameshval@bv@print{points}%
+  \fi%
+}%
+%% the name of the point
+\define@key{buildVoronoi}{meshpoint}[P]{\def\luameshval@bv@meshpoint{#1}}%
+%% the name of the circum point
+\define@key{buildVoronoi}{circumpoint}[P]{\def\luameshval@bv@circumpoint{#1}}%
+%% the mode for reading the points
+\define@choicekey*{buildVoronoi}{mode}[\val\nr]{int, ext}{%
+  \ifcase\nr\relax%
+  \def\luameshval@bv@mode{int}%
+  \or%
+  \def\luameshval@bv@mode{ext}%
+  \fi%
+}%
+%% the mode for reading the points
+\define@choicekey*{buildVoronoi}{delaunay}[\val\nr]{none, show}{%
+  \ifcase\nr\relax%
+  \def\luameshval@bv@delaunay{none}%
+  \or%
+  \def\luameshval@bv@delaunay{show}%
+  \fi%
+}%
+%% the name of the color of drawing
+\define@key{buildVoronoi}{color}[black]{\def\luameshval@bv@color{#1}}%
+%% the name of the color of drawing Voronoi
+\define@key{buildVoronoi}{colorVoronoi}[red]{\def\luameshval@bv@colorVoronoi{#1}}%
+%% the name of the color of drawing the bbox
+\define@key{buildVoronoi}{colorBbox}[black]{\def\luameshval@bv@colorbbox{#1}}%
+%
+\presetkeys{buildVoronoi}{tikz=false,bbox=none,scale, meshpoint,circumpoint,mode=int,print=none,color,colorVoronoi,colorBbox,delaunay=none}{}%
+%
+\newcommand{\buildVoronoiBW}[2][]{%
+  % #1 : optionnal arguments
+  % #2 : the string containing the list of points
+  % (x1,y1);(x2,y2);... or the name file containing the points
+  \setkeys{buildVoronoi}{#1} %
+  \def\MeshPoint{\luameshval@bv@meshpoint}%
+  \def\CircumPoint{\luameshval@bv@circumpoint}%
+  \ifKV@buildVoronoi@tikz% if we are using tikz
+  \directlua{%
+    buildVoronoiTikZBW("#2","\luameshval@bv@mode","\luameshval@bv@print","\luameshval@bv@bbox","\luameshval@bv@scale","\luameshval@bv@delaunay","\luameshval@bv@color","\luameshval@bv@colorbbox","\luameshval@bv@colorVoronoi")%
+  }%
+  \else % we are using MP
+  \mplibcolor{\luameshmpcolor}{\luameshval@bv@color}%
+  \mplibcolor{\luameshmpcolorBbox}{\luameshval@bv@colorbbox}%
+  \mplibcolor{\luameshmpcolorVoronoi}{\luameshval@bv@colorVoronoi}%
+  \directlua{%
+    buildVoronoiMPBW("#2","\luameshval@bv@mode","\luameshval@bv@print","\luameshval@bv@bbox","\luameshval@bv@scale","\luameshval@bv@delaunay")%
+  }%
+  %
+  \fi%
+}%
 %
 %
 %%%%%%%%%%%%%%%%% the draw Points macro
     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")%
+    printPointsTikZinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@tpi@mode","\luameshval@tpi@print","\luameshval@tpi@bbox","\luameshval@tpi@scale","\luameshval@tpi@color","\luameshval@tpi@colorbbox")%
   }%
   \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")%
   }%
 %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% the meshAddOnePointBW commande
-%%engine of drawing
+%%engine of draiwng
 \define@boolkey{MeshAddOneBW}{tikz}[true]{}%
 %% the scale
 \define@key{MeshAddOneBW}{scale}[1cm]{\def\luameshval@ap@scale{#1}}%

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.