请看下面的代码。我想要做的是填充图片中标记为红色的区域。我该怎么做呢?
\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}