\newpage \section{Transfers} % (fold) \label{sec:transfers} \subsection{Fom Lua to tkz-euclide or TikZ} % (fold) \label{sub:fom_lua_to_tkz_euclide_or_tikz} In this section, we'll look at how to transfer points, Booleans and numerical values. \subsubsection{Points transfer} % (fold) \label{ssub:points_transfer} We use an environment \tkzname{tkzelements} outside an environment \tkzname{tikzpicture} which allows us to carry out all the necessary calculations, then we launch the macro \Imacro{tkzGetNodes} which transforms the affixes of the table \tkzname{z} into \tkzname{Nodes}. It only remains to draw. Currently the drawing program is either \TIKZ\ or \pkg{tkz-euclide}. You have the possibility to use another package to trace but for that you have to create a macro similar to \tkzcname{tkzGetNodes}. Of course, this package must be able to store the points as does \TIKZ\ or \pkg{tkz-euclide}. \vspace*{1em} \begin{mybox} \begin{verbatim} \def\tkzGetNodes{\directlua{% for K,V in pairs(z) do local n,sd,ft n = string.len(K) if n >1 then _,_,ft, sd = string.find( K , "(.+)(.)" ) if sd == "p" then K=ft.."'" end end tex.print("\\coordinate ("..K..") at ("..V.re..","..V.im..") ;\\\\") end} }\end{verbatim} \end{mybox} See the section In-depth Study \ref{sec:in_depth_study} for an explanation of the previous code. The environment \tkzNameEnv{tkzelements} allows to use the underscore |_| and the macro \tkzcname{tkzGetNodes} allows to obtain names of nodes containing \tkzname{prime}. (see the next example) \begin{minipage}{0.5\textwidth} \begin{tkzexample}[latex=0cm,small,code only] \begin{tkzelements} scale = 1.2 z.o = point: new (0,0) z.a_1 = point: new (2,1) z.a_2 = point: new (1,2) z.ap = z.a_1 + z.a_2 \end{tkzelements} \begin{tikzpicture} \tkzGetNodes \tkzDrawSegments(o,a_1 o,a_2 o,a') \tkzDrawSegments[red](a_1,a' a_2,a') \tkzDrawPoints(a_1,a_2,a',o) \tkzLabelPoints(o,a_1,a_2,a') \end{tikzpicture} \end{tkzexample}% \end{minipage}% \begin{minipage}{0.5\textwidth} \begin{tkzelements} scale = 1.2 z.o = point: new (0,0) z.a_1 = point: new (2,1) z.a_2 = point: new (1,2) z.ap = z.a_1 + z.a_2 \end{tkzelements} \begin{tikzpicture} \tkzGetNodes \tkzDrawSegments(o,a_1 o,a_2 o,a') \tkzDrawSegments[red](a_1,a' a_2,a') \tkzDrawPoints(a_1,a_2,a',o) \tkzLabelPoints(o,a_1,a_2,a') \end{tikzpicture} \end{minipage}% \newpage % subsection fom_lua_to_tkz_euclide_or_tikz (end) \subsubsection{Other transfers} % (fold) \label{ssub:other_transfers} Sometimes it's useful to transfer angle, length measurements or boolean. For this purpose, I have created the macro (see \ref{sub:transfer_from_lua_to_tex}) \IEmacro{tkzUseLua(value)} \begin{verbatim} \begin{tkzelements} z.b = point: new (1,1) z.a = point: new (4,2) z.c = point: new (2,2) z.d = point: new (5,2) L.ab = line : new (z.a,z.b) L.cd = line : new (z.c,z.d) det = (z.b-z.a)^(z.d-z.c) if det == 0 then bool = true else bool = false end x = intersection (L.ab,L.cd) \end{tkzelements} The intersection of the two lines lies at a point whose affix is:\tkzUseLua{x} \begin{tikzpicture} \tkzGetNodes \tkzDrawPoints(a,...,d) \ifthenelse{\equal{\tkzUseLua{bool}}{true}}{ \tkzDrawSegments[red](a,b c,d)}{% \tkzDrawSegments[blue](a,b c,d)} \tkzLabelPoints(a,...,d) \end{tikzpicture} \end{verbatim} \begin{tkzelements} z.b = point: new (1,1) z.a = point: new (4,2) z.c = point: new (2,2) z.d = point: new (5,1) L.ab = line : new (z.a,z.b) L.cd = line : new (z.c,z.d) det = (z.b-z.a)^(z.d-z.c) if det == 0 then bool = true else bool = false end x = intersection (L.ab,L.cd) \end{tkzelements} The intersection of the two lines lies at a point whose affix is: \tkzUseLua{x} \vspace{1em} \hspace{\fill} \begin{tikzpicture} \tkzGetNodes \tkzInit[xmin =-1,ymin=-1,xmax=6,ymax=3] \tkzGrid\tkzAxeX\tkzAxeY \tkzDrawPoints(a,...,d) \ifthenelse{\equal{\tkzUseLua{bool}}{true}}{ \tkzDrawSegments[red](a,b c,d)}{% \tkzDrawSegments[blue](a,b c,d)} \tkzLabelPoints(a,...,d) \end{tikzpicture} \hspace{\fill} % subsubsection other_transfers (end) % subsubsection points_transfer (end) % section transferts (end) \endinput