How to draw a irregular circle(shape)?
Using the rand
function, you can write the \irregularcircle
macro:
\documentclass[tikz]{standalone}
\newcommand\irregularcircle[2]{% radius, irregularity
\pgfextra {\pgfmathsetmacro\len{(#1)+rand*(#2)}}
+(0:\len pt)
\foreach \a in {10,20,...,350}{
\pgfextra {\pgfmathsetmacro\len{(#1)+rand*(#2)}}
-- +(\a:\len pt)
} -- cycle
}
\begin{document}
\begin{tikzpicture}
\coordinate (c) at (0,0);
\coordinate (d) at (1,2);
\draw[blue,rounded corners=1mm] (c) \irregularcircle{1cm}{1mm};
\draw[red,rounded corners=1mm] (d) \irregularcircle{1cm}{1mm};
\end{tikzpicture}
\end{document}
Edit: a variant using let
operations (from the calc
library):
\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\newcommand\irregularcircle[2]{% radius, irregularity
let \n1 = {(#1)+rand*(#2)} in
+(0:\n1)
\foreach \a in {10,20,...,350}{
let \n1 = {(#1)+rand*(#2)} in
-- +(\a:\n1)
} -- cycle
}
\begin{document}
\begin{tikzpicture}
\coordinate (c) at (0,0);
\coordinate (d) at (1,2);
\draw[blue,rounded corners=.5mm] (c) \irregularcircle{1cm}{1mm};
\draw[red,rounded corners=.5mm] (d) \irregularcircle{1cm}{1mm};
\end{tikzpicture}
\end{document}
You can use plot
:
\documentclass{scrbook}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw plot[smooth, tension=.7] coordinates {(-3.5,0.5) (-3,2.5) (-1,3.5) (1.5,3) (4,3.5) (5,2.5) (5,0.5) (2.5,-2) (0,-0.5) (-3,-2) (-3.5,0.5)};
\end{tikzpicture}
\begin{tikzpicture}
\draw plot[smooth, tension=.8] coordinates {(-2.5,-0.5) (-3.5,0) (-2.5,0.5) (-3,1) (-2,1.5) (-2,3) (-1,2.5) (1,4.5) (2.5,3) (3,3.5) (3.5,3) (3,2) (4.5,2) (4.5,0) (3,1) (2.5,-0.5) (3.5,-1.5) (1.5,-1) (0.5,-2) (-2,-2.5) (-1.5,-1) (-2.5,-1.5) (-2.5,-0.5)};
\end{tikzpicture}
\end{document}
Using the same points as above the curve can be drawn using the excellent hobby
package:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{hobby}
\begin{document}
\begin{tikzpicture}[use Hobby shortcut,closed=true]
\draw (-3.5,0.5) .. (-3,2.5) .. (-1,3.5).. (1.5,3).. (4,3.5).. (5,2.5).. (5,0.5) ..(2.5,-2).. (0,-0.5).. (-3,-2).. (-3.5,0.5);
\end{tikzpicture}
\begin{tikzpicture}[use Hobby shortcut,closed=true]
\draw (-2.5,-0.5).. (-3.5,0).. (-2.5,0.5).. (-3,1).. (-2,1.5).. (-2,3).. (-1,2.5).. (1,4.5).. (2.5,3).. (3,3.5).. (3.5,3).. (3,2).. (4.5,2).. (4.5,0).. (3,1).. (2.5,-0.5).. (3.5,-1.5).. (1.5,-1).. (0.5,-2).. (-2,-2.5).. (-1.5,-1).. (-2.5,-1.5).. (-2.5,-0.5);
\end{tikzpicture}
\end{document}
Choose points as you wish and leave the rest to hobby
. For more details, use texdoc hobby
or texdoc.net.
Paul Gaborit's answer is a bit outdated. Now the rand
function is rnd
and there's the decorations
library which can be used to make irregular circles with sharp irregularities.
For smooth irregularities the plot
path specifier (used by user11232) can be used along with the rnd
function too, removing the necessity to create coordinates. The below MWE presents both solutions.
MWE
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}
\draw plot[domain=0:350, smooth cycle] (\x:2+rnd*0.5);
\draw[decoration={random steps, amplitude=2mm}, decorate] (4.5,0) circle (2);
\end{tikzpicture}
\end{document}