I'm trying to create a function that generates blobs with boundaries that have continuous curvature. As long as I pass individual coordinates to the function, everything works out well.
\documentclass{article}
\usepackage{tikz}
\newcommand{\smoothplot}[3]{%
% Smooth curve through 3 coordinates
\path [draw=red, line width = 5, smooth cycle]
plot coordinates {(#1) (#2) (#3)};
}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (5,5);
\coordinate (C) at (2,-2);
\smoothplot{A}{B}{C};
\end{tikzpicture}
\end{document}
But if I want to have an arbitrary number of arguments by passing in a list of coordinates, I can't make it work.
\documentclass{article}
\usepackage{tikz}
\newcommand{\smoothplot}[1]{%
% Smooth curve through coordinates given in a list
\path [draw=red, line width = 5, smooth cycle]
plot coordinates {\foreach \mycoord in #1 {(\mycord)}};
}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (5,5);
\coordinate (C) at (2,-2);
\smoothplot{A, B, C};
\end{tikzpicture}
\end{document}
It give me an error: Package tikz Error: Cannot parse this coordinate.
Can anyone show me how to extract the coordinates from the list in such a way that the plot operation can use them?

\typeouts before uploading the answer. (Another tool of this type is\show, but this interrupts the compilation.) – Feb 06 '19 at 01:16