Example: Intersecting rings

Published 2008-03-09 | Author: Dominique Würtz

This example shows how to fill the intersection area of two rings. The operation requires you to apply the even odd rule to the clipping path. Unfortunately you can not set some options directly when specifying the clipping path. You can easily solve this problem by putting the path inside a scope. (See Chapter 14.7 in the manual for an explanation)

Author:Dominique Würtz
Source:pgf-users mailing list

Download as: [PDF] [TEX]

Intersecting rings

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Intersecting rings
% Author: Dominique Würtz
% Source: http://www.nabble.com/Intersection-area-to15711124.html


% Define the rings. Store them in macros to make things
% more flexible. 
\def\ringa{(-1,0) circle (2) (-1,0) circle (3)}
\def\ringb{(1,0) circle (2) (1,0) circle (3)}

    % First we fill the intersecting area
    % The \clip command does not allow options, therefore 
    % we have to use a scope to set the even odd rule. 
    \begin{scope}[even odd rule]
        % Define a clipping path. All paths outside ringa will
        % be cut because the even odd rule is set. 
        \clip \ringa;
        % Fill ringb. Since the even odd rule is set, only the
        % ring will be filled, not the hole in the middle.  
        \fill[fill=orange] \ringb;
    % Then we draw the rings
    \draw \ringa;
    \draw \ringb;



Adding comments is currently not enabled.