I am trying to draw a curve by calculating every point's position in a \foreach loop (potentially hundreds of points).
Since the calculation is quite complex, I use \pgfmathsetmacro multiple times to store intermediate results.
Here is a MWE of what I currently have. It draws the path I want it to, but it is not a continuous path, so I can't easily fill it.
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \t in {0.0,0.1,...,1}{
% complex calculation depending on \t here with lots of \pgfmathsetmacro s
% The values of the pos variables obviously depend on the previous calculations in my actual use case
\pgfmathsetmacro \posX {\t}
\pgfmathsetmacro \posY {\t * \t}
\pgfmathsetmacro \posXNext {\t + 0.1}
\pgfmathsetmacro \posYNext {(\t + 0.1) * (\t + 0.1)}
\draw (\posX, \posY) -- (\posXNext, \posYNext);
}
\end{tikzpicture}
\end{document}
I can't use the solution suggested here:
Draw a path between many nodes using foreach, because of all the \pgfmathsetmacros before the \draw call (or at least I couldn't get it to work).
Here is an image of the result of the MWE and what I would like to achieve:
If there is a completely different way of doing this, that's ok too.
Thanks.




\draw...), you can call\pgfextra{...}to do calculation... – Paul Gaborit Apr 28 '19 at 14:37