![如何为给定图形中的多边形特定区域着色](https://linux22.com/image/409918/%E5%A6%82%E4%BD%95%E4%B8%BA%E7%BB%99%E5%AE%9A%E5%9B%BE%E5%BD%A2%E4%B8%AD%E7%9A%84%E5%A4%9A%E8%BE%B9%E5%BD%A2%E7%89%B9%E5%AE%9A%E5%8C%BA%E5%9F%9F%E7%9D%80%E8%89%B2.png)
请指导我如何在给定的图中为 ODBE 区域着色....
\begin{tikzpicture}
\tikzset{dot/.style={circle,inner sep=1pt,fill,label={#1},name=#1}}
\draw (0,5)--(0,0)node{O}--(5,0);
\draw [name path=P1] (2,0)node(b){D} -- (0,4)node{A};
\draw [name path=P2] (3,0)node(b){C} -- (0,2)node(b){E};
\path [name intersections={of=P1 and P2,by=B}];
\node [dot=B] at (B) {};
\end{tikzpicture}
请指导,非常感谢,这将有很大的帮助...
答案1
以下代码将创建您在附图中看到的内容。您需要声明一个背景层,将填充的多边形放在后面,这样它就不会覆盖节点的标签。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\pgfdeclarelayer{bg} % declare background
\pgfsetlayers{bg,main} % order of layers (main = standard layer)
\begin{document}
\begin{tikzpicture}
\tikzset{dot/.style={circle,inner sep=1pt,fill,label={#1},name=#1}}
\draw (0,5)-- (0,0)node(o){O} --(5,0);
\draw [name path=P1] (2,0)node(d){D} -- (0,4)node(a){A};
\draw [name path=P2] (3,0)node(c){C} -- (0,2)node(e){E};
\path [name intersections={of=P1 and P2,by=b}];
\node [dot=B] at (b) {};
\begin{pgfonlayer}{bg} % select background
\path [fill=green!50] (o.center) -- (d.center) -- (b) -- (e.center) -- cycle;
\end{pgfonlayer}
\end{tikzpicture}
\end{document}