填充由多条路径包围的区域

填充由多条路径包围的区域

请看下面的代码。我想要做的是填充图片中标记为红色的区域。我该怎么做呢?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
    \begin{tikzpicture}
    \draw (0,0) -- (2,0);

    \draw(0,0) -- (0,2.3); 

    \begin{scope}
    \clip (0,0) rectangle (2,2.7);
    \draw[name path=arc] (0,2.3) arc (-105:-60:3.5);
    \end{scope}

    \path[name path=l] (2,0) -- (2,2.6);
    \path[name intersections={of=arc and l, by=x}];
    \draw (2,0) -- (x);
    \draw[densely dotted] (0,2.3) -- (0,2.7) (x) -- (2,2.7) (0,2.7) -- (2,2.7);
    \draw[densely dotted] (0,2.2) -- (2,2.2);
    \node at (2.62,2.2) {$h_0-h_1$};
    \node at (2.2,2.7) {$h_0$};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

开始你的图片

\begin{scope}
\clip (0,0) -- (0,2.3) arc (-105:-60:3.5) |- (0,0);
\fill[red] (0,2.2) rectangle (2,2.7);
\end{scope}

在此处输入图片描述

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
    \begin{tikzpicture}
    \begin{scope}
    \clip (0,0) -- (0,2.3) arc (-105:-60:3.5) |- (0,0);
    \fill[red] (0,2.2) rectangle (2,2.7);
    \end{scope}

    \draw (0,0) -- (2,0);

    \draw (0,0) -- (0,2.3); 

    \begin{scope}
    \clip (0,0) rectangle (2,2.7);
    \draw[name path=arc] (0,2.3) arc (-105:-60:3.5);
    \end{scope}

    \path[name path=l] (2,0) -- (2,2.6);
    \path[name intersections={of=arc and l, by=x}];
    \draw (2,0) -- (x);
    \draw[densely dotted] (0,2.3) -- (0,2.7) (x) -- (2,2.7) (0,2.7) -- (2,2.7);
    \draw[densely dotted] (0,2.2) -- (2,2.2);
    \node at (2.62,2.2) {$h_0-h_1$};
    \node at (2.2,2.7) {$h_0$};
    \end{tikzpicture}
\end{document}

相关内容