The Situation
Many vector graphics editors (for instance, Inkscape, Adobe Illustrator and Microsoft Visio) permit the synthesis of new shapes by union, difference or intersection operators. A collection of Venn diagrams on TeXample demonstrates the use of clipping to fill unions and differences of shapes, however I have not yet seen any examples of construction of new shape outlines through boolean operations. Does this functionality exist in TikZ at all?
A Workaround
I have devised a workaround for the little diagram that I'm working on that takes advantage of Z-ordering to give the impression of a composite outline (i.e. the union of several shapes) by drawing a shape, drawing intersecting shapes and then redrawing the original shape without a line style. It is necessary to slightly shrink the redrawn shape to get constant apparent line weight all the way around:
\begin{tikzpicture}[scale=1]
% Draw all of the necessary shapes.
\draw[fill=gray!30] ( 0.0, 0.0) circle (1cm and 0.5cm);
\draw[fill=gray!30] ( 0.4, 0.5) circle (0.3cm);
\draw[fill=gray!30] (-0.4, -0.5) circle (0.3cm);
\draw[fill=gray!30] (-0.4, 0.4) circle (0.3cm);
\draw[fill=gray!30] ( 0.4, -0.4) circle (0.3cm);
% Now draw a grey circle over the top with no outline.
\draw[fill=gray!30,draw=none] (0,0) circle (0.99cm and 0.49cm);
\draw[] (0,0) node {Q.M.};
\end{tikzpicture}
Needless to say this is probably the wrong way to go about this problem. Any better ways?
Example Output
at 200% zoom, as viewed in Evince.
Further Explorations
In my dabbling I have determined that fairly interesting effects can be had by judicious z-ordering of shapes with and without borders, for instance, giving the appearance of an ellipsoid with protrusions in front and behind. Shared in the hope it might be useful to someone.
\begin{tikzpicture}[scale=1]
% Draw lobes behind.
\draw[fill=gray!30] ( 0.4, 0.4) circle (0.3cm);
\draw[fill=gray!30] (-0.4, -0.4) circle (0.3cm);
% Draw ellipsoid.
\draw[fill=gray!30] ( 0.0, 0.0) circle (1cm and 0.5cm);
% Draw lobes in front.
\draw[fill=gray!30] (-0.4, 0.4) circle (0.3cm);
\draw[fill=gray!30] ( 0.4, -0.4) circle (0.3cm);
% Now draw a grey circle over the top with no outline,
% shrunken to only clip a section of the lobes in front.
\draw[fill=gray!30,draw=none] (0,0) circle (0.80cm and 0.35cm);
\draw[] (0,0) node {Q.M.};
\end{tikzpicture}
even odd rule
. You can have a look at this question: tex.stackexchange.com/questions/9681/… – Leo Liu Feb 19 '11 at 14:09even odd rule
appears to only pertain to fills, rather than outlines. – Richard Terrett Feb 19 '11 at 14:21cloud
node shape (see section 48.4 of the v2.10 manual or section 39.4 in the v2.00 manual). – Caramdir Feb 19 '11 at 17:14cloud
object itself - thanks for alerting me to its capabilities. Regrettably, I require a shape with puffs of equal radius, which appears to be only possible in the degenerate (circular) case ofcloud
. I may end up using the circularcloud
anyhow as this is probably too much stuffing around for a simple schema. To give some background, this shape is representing a bounding volume in a chemistry calculation that has been capped with protruding hydrogen atoms. Accordingly, symmetry and equal puff radii are desired. – Richard Terrett Feb 21 '11 at 3:35arc
paths, but that would involve some calculations. – Caramdir Feb 21 '11 at 4:42