# can one write tikz in lua code directly?

Sorry if this question sounds basic and naive for the experts, but something I wondered about for sometime.

Since tikz itself is implemented in lua interviews/2015-till-tantau

Then why can't one write tikz code in Lua syntax directly?

What I mean, is that instead of writing the tikzpicture code itself in Latex syntax in the document using all those \ everywhere, can one write the same thing, but using lua function inside a \begin{luacode}... \end{luacode} environment, and using some direct lua->tikz API calls and hence using lua syntax.

I mean, instead of doing this now

 latex-->tikzpicture API in latex code--->lua tikz engine


Do

 latex-->luacode function-->tikzpicture API in lua code--->lua tikz engine


So instead of writing \draw[....] one would write draw(...) inside luacode procedure. Since the tikz itself is written in lua, it must have this API already in lua?, so why not use this API directly from lua?

I find lua much easier to program in than using Latex and tikz code in Lua would be much easier to read, use lua variables, computation, etc... than having to do all this using Latex code.

ps. I know the above would work only with luatex only, but that is ok. This is what I use now anyway.

• TikZ (like pgf) is coded in TeX. Lua is used only to implement graph drawing algorithms... – Paul Gaborit May 27 at 6:38
• I think you slightly misunderstood that interview. TikZ is mostly written in TeX, almost everything is usable with pdfTeX, LuaTeX and XeTeX, not only with LuaTeX. In that interview he was referring to automatic drawing of graphs, a mathematical concept, a graph is a set of nodes that are connected by edges and arcs (arcs being directed edges). The things described in the pgfmanual in Part IV "Graph Drawing" are programmed in Lua, not the rest of TikZ. – Skillmon May 27 at 6:52
• Of course you could write your TikZ code in \directlua or similar, but it would end in using Lua to produce valid TeX code that is valid TikZ syntax. That's because pgf and TikZ are only completely implemented in TeX (to my knowledge there is no port to any other language). – Skillmon May 27 at 6:54
• context (which does really much in lua, even more with the new engine LTMX) does the drawing with metapost. – Ulrike Fischer May 27 at 6:59