\section{Getting started}

\subsection{The first code}

A quick introduction to get you started.
We assume that the packages \tkzNamePack{tkz-euclide} and \tkzNamePack{tkz-elements} are installed.
Compile the following code using the \tkzEngine{lualatex} engine; you should obtain a straight line
passing through points $A$ and $B$.

\medskip
\noindent
\textbf{Note.}
The package \tkzNamePack{tkz-elements} performs all geometric definitions and computations in Lua,
while \tkzNamePack{tkz-euclide} is mainly used for drawing.
For this reason, the \texttt{mini} option of \tkzNamePack{tkz-euclide} is recommended.
If a compilation problem occurs, simply load \tkzNamePack{tkz-euclide} without this option.


\begin{mybox}{}
\begin{minipage}{.6\textwidth}
  \begin{tkzexample}[code only]
  % !TEX TS-program = lualatex
  \documentclass{article}
  \usepackage[mini]{tkz-euclide}
  \usepackage{tkz-elements}
  \begin{document}
  \directlua{
    init_elements()
    z.A = point(0, 1)
    % or z.A = point:new(0, 1)
    z.B = point(2, 0)
  }
  \begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawLine(A,B)
   \tkzDrawPoints(A,B)
   \tkzLabelPoints(A,B)
  \end{tikzpicture}
  \end{document}
  \end{tkzexample}
\end{minipage}
\begin{minipage}{.4\textwidth}
  \directlua{
    z.A = point(0, 1)
    z.B = point(2, 0)
  }
  \begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawLine(A,B)
   \tkzDrawPoints(A,B)
   \tkzLabelPoints(A,B)
  \end{tikzpicture}
\end{minipage}
\end{mybox}

\subsection{Key points}

The following points are essential for most of the codes in this documentation.

\begin{itemize}
\item \verb|% !TEX TS-program = lualatex|.
Compilation must be done with \code{lualatex}. This line is optional if your editor is already configured accordingly.

\item \verb|\usepackage[mini]{tkz-euclide}|.
The use of \tkzNamePack{tkz-euclide} is optional; however, if it is loaded, the \code{mini} option is recommended.
It loads only the drawing macros, while all computations are handled by \code{lua}.
\textbf{Important:} at the current stage, some drawing macros are not yet fully independent of computation macros.
If a compilation problem occurs, simply load \tkzNamePack{tkz-euclide} without the \code{mini} option.

\item \verb|\usepackage{tkz-elements}|.
This package is required. It provides the Lua-based geometry engine and support macros used together with \tkzNamePack{tkz-euclide}.

\item \verb|\directlua{...}|.
All geometric definitions and computations are placed inside this macro (or within a \texttt{tkzelements} environment).

\item \verb|init_elements()|.
This function should be called at the beginning of each Lua section.
It resets internal tables and clears global variables used by \tkzNamePack{tkz-elements}.

\item \verb|\tkzGetNodes|.
This macro must be placed at the beginning of the \code{tikzpicture} environment.
It transfers the points defined in Lua to TikZ as usable nodes.
\end{itemize}



\subsection{Testing}

To test your installation and follow the examples in this documentation, you need to load two packages: \tkzNamePack{tkz-euclide} and \tkzNamePack{tkz-elements}. The first package automatically loads \tkzNamePack{\TIKZ}, which is necessary for all graphical rendering.


The \tkzname{Lua} code is provided as an argument to the \tkzMacro{lualatex}{directlua} macro. I will often see  this code block as the \tkzname{Lua part}\footnote{This code can also be placed in an external file, e.g., \texttt{file.lua}.}. This part depends entirely on the \tkzNamePack{tkz-elements} package.

A crucial component in the \tkzEnv{tikz}{tikzpicture} environment is the macro \tkzMacro{tkz-elements}{tkzGetNodes}. This macro transfers the points defined in \tkzname{Lua} to \tkzNamePack{\TIKZ} by creating the corresponding nodes. All such points are stored in a table named \tkzname{z} and are accessed using the syntax \tkzname{z.label}. These labels are then reused within \tkzNamePack{tkz-euclide}.

When you define a point by assigning it a label and coordinates, it is internally represented as a complex number — the affix of the point. This representation allows the point to be located within an orthonormal Cartesian coordinate system.

If you want to use a different method for rendering your objects, this is the macro to modify. For example, Section~\ref{sec:metapost} presents \tkzMacro{tkz-elements}{tkzGetNodesMP}, a variant that enables communication with \code{MetaPost}.

Another essential element is the use of the function \tkzFct{tkz-elements}{init\_elements()}, which clears internal tables\footnote{All geometric objects are stored in Lua tables. These tables must be cleaned regularly, especially when creating multiple figures in sequence.} when working with multiple figures.

If everything worked correctly with the previous code, you're ready to begin creating geometric objects. Section~\ref{sec:class_and_object} introduces the available options and object structures.

Finally, it is important to be familiar with basic drawing commands in \tkzNamePack{tkz-euclide}, as they will be used to render the objects defined in \tkzname{Lua}.
\endinput