How can I draw an egg using TikZ?

Here is the only solution using the perfect (!) parametric equation of an egg (cf. Equation of Egg Shaped Curve) :

  • x = H × 0.78 × cos(t × 0.25) × sin(t)
  • y = H × cos(t)

(where H is the height of the egg and t is in [-π,π])

enter image description here

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \def\eggheight{3cm}
  \path[ball color=orange!60!gray]
  plot[domain=-pi:pi,samples=100]
  ({.78*\eggheight *cos(\x/4 r)*sin(\x r)},{-\eggheight*(cos(\x r))})
  -- cycle;
\end{tikzpicture}
\end{document}

Edit: a second version with better colors.

enter image description here

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \def\eggheight{3cm}
  \path[preaction={fill=orange!50!white},
  ball color=orange!60!gray,fill opacity=.5]
  plot[domain=-pi:pi,samples=100]
  ({.78*\eggheight *cos(\x/4 r)*sin(\x r)},{-\eggheight*(cos(\x r))})
  -- cycle;
\end{tikzpicture}
\end{document}

The to[in=angle,out=angle] and ball shading constructs are helpful for this:

Code

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[looseness=0.75,ball color=orange!70!gray] (-2,0) arc (180:360:2) to[out=90,in=0] (0,3) to[out=180,in=90] (-2,0) -- cycle;
\end{tikzpicture}
\end{document}

Result

enter image description here


Edit 1: I think this pudding is overegged.

Code

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[looseness=0.9,ball color=orange!70!gray!50,draw=none] (-2,0) arc (180:360:2) to[out=90,in=0] (0,3) to[out=180,in=90] (-2,0) -- cycle;
\end{tikzpicture}
\end{document}

Result

enter image description here


Edit 2: Following percusse's idea, I added a few freckles:

Code

\documentclass[tikz,border=5mm]{standalone}

\begin{document}

\begin{tikzpicture}
    \colorlet{myEgg}{orange!70!gray!50}
    \draw[looseness=0.9,ball color=orange!70!gray!50,draw=none,clip] (-2,0) arc (180:360:2) to[out=90,in=0] (0,3) to[out=180,in=90] (-2,0) -- cycle;
    %\fill[blue] (-3,-3) rectangle (3,3);
    \foreach \x in {1,...,100}
    {   \pgfmathsetmacro{\rDot}{random()/50}
        \pgfmathsetmacro{\xCoo}{rand*2}
        \pgfmathsetmacro{\yCoo}{rand*2.5+0.5}
        \pgfmathsetmacro{\dColor}{100-60*sqrt(pow(\xCoo+0.5,2)+pow(\yCoo-1.4,2))/2.6}
        \fill[myEgg!\dColor!black] (\xCoo,\yCoo) circle (\rDot);
    }
\end{tikzpicture}

\end{document}

Result

enter image description here


Edit 3: special request of ガベージコレクタ: here's 512 frog spawn (immersed in water):

Code

\documentclass[tikz,border=5mm]{standalone}
\usepackage{xifthen}
\usepackage{fp}

\newcommand{\frogegg}[2]%
{ \draw[ball color=black!80] (#1) circle (#2*0.25cm);
    \draw[ball color=cyan!5!gray,opacity=0.1] (#1) circle (#2*1cm);
}

\pgfdeclarelayer{background layer}
\pgfsetlayers{background layer,main}

\begin{document}

\begin{tikzpicture}
[   x={(-27:1cm)},
    y={(203:1cm)},
    z={(95:1cm)},
]
\foreach \x in {0,...,7}
{ \foreach \y in {0,...,7}
    {   \foreach \z in {0,...,7}
        {   \pgfmathsetmacro{\xco}{\x+rand/3}
            \pgfmathsetmacro{\yco}{\y+rand/3}
            \pgfmathsetmacro{\zco}{\z+rand/3}
            \pgfmathsetmacro{\rad}{1+rand/3}
            \frogegg{\xco,\yco,\zco}{\rad}
        }
    }
}
\begin{pgfonlayer}{background layer}
    \fill[blue!50!gray] (current bounding box.south west) rectangle (current bounding box.north east);
\end{pgfonlayer}
\end{tikzpicture}

\end{document}

Result

enter image description here


A quick fix for egreg's egg. Thank you MATLAB for running so slow.

I've tried to find a dirt mask but couldn't find anything which would give a more realistic result. Also the shadow shading is a little off but the original render is also wrong.

\documentclass[tikz]{standalone}
\usetikzlibrary{shadings}
\definecolor{eggshell}{RGB}{252,230,201}
\pgfdeclareradialshading{eggshading}{\pgfpoint{1cm}{1cm}}%
{color(0cm)=(eggshell!80);
color(0.5cm)=(brown!75!eggshell);
color(0.7cm)=(brown);
color(0.9cm)=(brown!70!black);
color(1.2cm)=(black)
}
\pgfdeclareradialshading{eggshadow}{\pgfpointorigin}%
{color(0cm)=(black);
color(2mm)=(gray!80);
color(3mm)=(gray!40);
%color(0.3cm)=(black!5!white);
color(7mm)=(white)
}

\begin{document}
\begin{tikzpicture}
\begin{scope}[yscale=0.93,transform shape]
    \node[xscale=2,yscale=0.3,shading=eggshadow,circle,minimum size=7mm] at (0,2.75mm){};
    \shade[shading=eggshading] (0,2.7mm)..controls (9mm,0.25cm) and (7mm,2cm)%
    ..(0,20.5mm)..controls(-7mm,2cm) and (-9mm,2.5mm)..(0,2.7mm)--cycle;
\end{scope}
    \node[anchor=south] at (2,0) {\includegraphics[height=2cm]{brownegg}};
\end{tikzpicture}
\end{document}

enter image description here

Tags:

Tikz Pgf

Fun