# Drawing nonuniform bubble [duplicate]

I need to draw a nonuniform text bubble and fitting the text inside of it.

## marked as duplicate by Guilherme Zanotelli, ebosi, Stefan Pinnow, user13907, Steven B. SegletesJan 10 '17 at 14:22

• hi ! show us a MWE ; And maybe tikz could help you – flav Jan 10 '17 at 9:58
• @GuilhermeZanotelli this solves the second part only of my question, thanks. – Ahmed Hawary Jan 10 '17 at 10:03
• @AhmedHawary, second part? What's the first? – Guilherme Zanotelli Jan 10 '17 at 10:04
• @GuilhermeZanotelli 1-Drawing a non-uniform bubble. 2- Fitting the text. Sorry if the questions is not clear enough. – Ahmed Hawary Jan 10 '17 at 11:00

Here's a bubble:

\documentclass{standalone}
\usepackage{tikz
\usetikzlibrary{calc,fit,intersections}
\begin{document}
\begin{tikzpicture}
\draw  plot [smooth,tension=1.3] coordinates {(1.cm+rand*.1cm,.2cm+rand*.1cm) (0cm+rand*0cm,-1cm+rand*.1cm) (-1cm+rand*0.1cm,0cm+rand*0.1cm) (0cm+rand*0.1cm,1cm+rand*0.1cm) (1.cm+rand*.1cm,-.2cm+rand*.1cm)};
\end{tikzpicture}
\end{document}


You can always hard-code the coordinates instead of the random ones I've used.

Putting text inside it is quite simple

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,fit,intersections}
\begin{document}
\begin{tikzpicture}
\draw  plot [smooth,tension=1.3] coordinates {(1.cm+rand*.1cm,.2cm+rand*.1cm) (0cm+rand*0cm,-1cm+rand*.1cm) (-1cm+rand*0.1cm,0cm+rand*0.1cm) (0cm+rand*0.1cm,1cm+rand*0.1cm) (1.cm+rand*.1cm,-.2cm+rand*.1cm)};
\node[text width=1.4cm] at(0,0) {\small{This is some text in a bubble}};
\end{tikzpicture}
\end{document}


Here it's a bit nicer to use:

\documentclass{standalone}
\usepackage{shapepar}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{calc,fit,intersections}
\newcommand\bubblenodetext[3]{\node [draw=none, shape=circle, text width=0cm, inner sep=5mm] at (#1,#2) (bubblenode){\shapepar{\circleshape} #3\par};
\def\startendoffset{3mm}
\draw  plot [smooth,tension=1.3] coordinates {($(bubblenode.east)+(\startendoffset,\startendoffset)$) (bubblenode.south) (bubblenode.west) (bubblenode.north) ($(bubblenode.east)+(\startendoffset,-\startendoffset)$)};
}
%change draw=none to draw=red to see the line bounding the text.
\newcommand\randombubblenodetext[3]{\node [draw=none, shape=circle, text width=0cm, inner sep=2mm] at (#1,#2) (bubblenode){\shapepar{\circleshape} #3\par};
\def\startendoffset{3mm}
\def\randomfactor{3mm}
\draw  plot [smooth,tension=1.3] coordinates {($(bubblenode.east)+(\startendoffset+rnd*\randomfactor,\startendoffset+rand*\randomfactor)$)
($(bubblenode.south)+(rand*\randomfactor,-rnd*\randomfactor)$)
($(bubblenode.west)+(-rnd*\randomfactor,rand*\randomfactor)$)
($(bubblenode.north)+(rand*\randomfactor,rnd*\randomfactor)$)
($(bubblenode.east)+(\startendoffset+rnd*\randomfactor,-\startendoffset+rand*\randomfactor)$)};
}

\begin{document}
\begin{tikzpicture}
\bubblenodetext {0}{0}{Now we automate the bubble.  We can still fill it with text.}
\randombubblenodetext{5}{0}{This is a slightly random bubble.  We can still fill it with text.}
\end{tikzpicture}
\end{document}


In the right-hand example I've also reduce the inner sep -- you need to strike a balance here as the text doesn't really respond to the shape I've drawn, but to a circle (see comment on line 10). The code was shamelessly stolen from Count Zero's answer to Fitting text to a shape in TikZ.

Things to tweak to get the look you're going for: inner sep tension, \startendoffset, \randomfactor (which you may want to set to 0).