[Tex/LaTex] Amoeba shape with TikZ

diagramstikz-pgf

I would like to draw generic amoeba-like shapes with TikZ and don't really want to think too deeply about its boundary. Basically a closed connected set with smooth locally convex boundaries.

Any ideas how to do this easily?

Best Answer

More realistic amoeba with PSTricks.

First Version

Please skip this first version (as there is a small glitch) and jump to the final version.

In this version I use \psparametricplot. After meticulously figuring out its behavior, I noticed that the last node is always included to create the closed curve. As a result, the first node and the last node are on the same radial line that make the curve has a visual defect on the curved line joining them.

I have no idea how to exclude the last node when using \psparametricplot.

enter image description here

\documentclass[pstricks]{standalone}
\usepackage{pst-plot}
\psset
{
    plotstyle=ccurve,
    fillstyle=solid,
    fillcolor=gray,
}
\begin{document}
\begin{pspicture}(-3,-3)(3,3)
\psparametricplot[plotpoints=40]{0}{360}{/R rand 1001 mod 1000 div 1.5 add def R t PtoC}
\end{pspicture}
\end{document}

Animation

enter image description here

\documentclass[pstricks]{standalone}
\usepackage{pst-plot}
\psset
{
    plotstyle=ccurve,
    fillstyle=solid,
    fillcolor=gray,
}

\begin{document}
\multido{\i=4+4}{20}{%
\begin{pspicture}(-3,-3)(3,3)
\psparametricplot[plotpoints=\i]{0}{360}{/R rand 1001 mod 1000 div 1.5 add def R t PtoC}
\end{pspicture}}
\end{document}

Final version

In this version I use \curvepnodes to produce a list of nodes. \Pnodecount represents the index of the last element.

Therefore,

\multido{\i=0+1}{\Pnodecount}{\xdef\points{\points (P\i)}}

exludes the last node.

One advantage of using \curvepnodes is that we don't need to calculate the angle step.

enter image description here

\documentclass[pstricks]{standalone}

\usepackage{pst-node,pst-plot}
\psset{fillstyle=solid,fillcolor=gray}

\def\points{}
\pstVerb{666 srand}
\def\N{25}

\begin{document}
\begin{pspicture}(-3,-3)(3,3)
\curvepnodes[plotpoints=\N]{0}{360}{rand 16 mod 15 div 1.5 add t PtoC}{P}
\multido{\i=0+1}{\Pnodecount}{\xdef\points{\points (P\i)}}
\expandafter\psccurve\points
\end{pspicture}
\end{document}

Animation

enter image description here

\documentclass[pstricks]{standalone}

\usepackage{pst-node,pst-plot}
\usepackage{graphicx}

\newsavebox\IBox
\savebox\IBox{\includegraphics[width=6cm]{example-grid-100x100pt}}
\psset
{
    fillstyle=solid,
    fillcolor=gray,
    xunit=\dimexpr\wd\IBox/6,
    yunit=\dimexpr\ht\IBox/6,
}

\pstVerb{666 srand}

\begin{document}
\multido{\io=15+5}{10}{%
\def\points{}%
\begin{pspicture}(-3,-3)(3,3)
\curvepnodes[plotpoints=\io]{0}{360}{rand 16 mod 15 div 1.5 add t PtoC}{P}
\multido{\ii=0+1}{\Pnodecount}{\xdef\points{\points (P\ii)}}
\begin{psclip}{\expandafter\psccurve\points}
    \rput(0,0){\usebox\IBox}
\end{psclip}
\end{pspicture}}
\end{document}