突出显示交叉点

突出显示交叉点

我想突出显示C下面欧拉图中的区域。我尝试使用fill opacity命令,但无法C单独突出显示。我应该使用intersections库来找出和的交点坐标CB继续吗?有人能帮我吗?

在此处输入图片描述

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
        \draw[fill=green, draw = black,fill opacity=0.5] (-1.5,0) circle (3);
        \draw[fill=blue!30!white, draw = black,fill opacity=0.5] (1.5,0) circle (3);
        \node at (-2,1) (B) {\large\textbf{B}};
        \node at (2,1) (C) {\large\textbf{C}};
        \node at (0,0) (D) {\large\textbf{D}};
\end{tikzpicture}
\end{document}

答案1

我用了保罗·加博利invclip风格来自his answer如何在 TikZ 中反转“剪辑”选择?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,positioning}

\tikzset{invclip/.style={clip,insert path={
      (-16383.99999pt,-16383.99999pt) rectangle (16383.99999pt,16383.99999pt)
    }}}


\begin{document}

\begin{tikzpicture}
% The intersection region D
\begin{scope}
\clip (1.5,0) circle (3cm);
\clip (-1.5,0) circle (3cm);
\fill[blue,fill opacity=0.2] (-1.5,0) circle [radius=3cm];
\end{scope}
% The B+D region
\begin{scope}
\clip (-1.5,0) circle (3cm);
\fill[green,fill opacity=0.2] (-1.5,0) circle [radius=3cm];
\end{scope}
\node at (-2,1) (B) {\large\textbf{B}};
\node at (0,0) (D) {\large\textbf{D}};
% Region C
\begin{pgfinterruptboundingbox} % useful to avoid the rectangle in the bounding box
    \path[invclip]
    (-1.5,0) circle (3cm);
  \end{pgfinterruptboundingbox} 
\fill[blue,fill opacity=0.9] (1.5,0) circle [radius=3cm];
\node at (2,1) (C) {\large\textbf{C}};
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案2

您可以使用两个clip命令来完成此操作:

代码

\documentclass[tikz,border=2mm]{standalone}
% declare a new layer
\pgfdeclarelayer{background} 
% give the order of layers from back to front
\pgfsetlayers{background,main}

\begin{document}
\begin{tikzpicture}
    \draw[fill=green, draw = black,fill opacity=0.2] (-1.5,0) circle (3);
    \draw[fill=blue!50, draw = black,fill opacity=0.2] (1.5,0) circle (3);
    \node at (-2,1) (B) {\large\textbf{B}};
    \node at (2,1) (C) {\large\textbf{C}};
    \node at (0,0) (D) {\large\textbf{D}};
    % begin a background layer to avoid painting over stuff
    \begin{pgfonlayer}{background}
        % scope to keep clipping local
        \begin{scope}
            % clip a large enough rectangle, then cut out the left circle
            \clip (-4.5,-3) rectangle (4.5,3) (-1.5,0) circle (3);
            % clips do stack; so clip only the left circle from the remaining region --> region C remains
            \clip (1.5,0) circle (3);
            % fill right circle, due to clipping only region C
            \fill[blue!50,opacity=1] (-5,-4) rectangle (5,4);
        \end{scope}
    \end{pgfonlayer}    
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

相关内容