The code adds some completely useless invisible (or rather white) stuff. The lines
\clip(0pt,403pt) -- (389.957pt,403pt) -- (389.957pt,99.6166pt) -- (0pt,99.6166pt) -- (0pt,403pt);
\color[rgb]{1,1,1}
\fill(3.76406pt,399.236pt) -- (380.923pt,399.236pt) -- (380.923pt,253.19pt) -- (3.76406pt,253.19pt) -- (3.76406pt,399.236pt);
\fill(53.4497pt,394.719pt) -- (374.901pt,394.719pt) -- (374.901pt,289.325pt) -- (53.4497pt,289.325pt) -- (53.4497pt,394.719pt);
draw a white background that is larger than the actual picture. TikZ sees that and thinks it is part of the picture. Simply removing/uncommenting these lines removes most of the whitespace.
Near the end of the first scope,
\color[rgb]{1,1,1}
\fill(3.76406pt,249.426pt) -- (386.193pt,249.426pt) -- (386.193pt,103.381pt) -- (3.76406pt,103.381pt) -- (3.76406pt,249.426pt);
does the same.
Additionally (near the end of the second scope
),
\pgftext[center, base, at={\pgfpoint{220.95pt}{106.392pt}}]{\sffamily\fontsize{9}{0}\selectfont{\textbf{ }}}
adds a blank node below the picture, again enlarging the bounding box.
Removing all those lines gives a tight bounding box.
As far as I know, TikZ cannot do the cropping for you, as it can't know whether the white stuff is intentional or not (there might for example be a dark background behind the image so that white is visible).
You can either use an integer number of puffs or the intersections
library and find the points manually.
Notes:
- I used named coordinates for
(2,1)
and (2,2)
to not repeat hard-coded coordinates.
- The anchor
.center
is neede because in the second example (the one to (2,1)
) the (cloud) -- (2,1)
does not intersect with the cloud’s border.
Code
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes,intersections}
\begin{document}
\begin{tikzpicture}
\node[
name path=cloud,
cloud, cloud puffs=15.7,
minimum width=3cm, draw,
] (cloud) at (0,0) {Cloud};
\path[name path=path22] (cloud.center) -- (2, 2) coordinate (to22);
\path[name path=path21] (cloud.center) -- (2, 1) coordinate (to21);
\draw[->,
name intersections={of=cloud and path22,name=from22},
name intersections={of=cloud and path21,name=from21}
] (from22-1) edge (to22)
(from21-1) to (to21);
\end{tikzpicture}
\end{document}
Output
Best Answer
In this case the TeX grouping braces are the source of error:
If you choose:
(max about 1.44 instead of 2), you can see the arrowhead.