我知道这个问题已经被问过几次了,和我的问题类似。但是,我不知道我做错了什么。我想给这个四边形上色。
\begin{tikzpicture}
\draw (3,-.5) to [<-, bend right=10] (1.5,0) node[left]{};
\draw (2,-1) to [<-, bend left=10] (.5,-.8) node[left]{};
\draw[dashed] (2,-1) -- (3,-.5) node[left] {};
\draw (.5,-.8) to (1.5,0) node[left]{};
\end{tikzpicture}
您可能需要包含下面的一些内容才能编译它。
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{verbatim}
\usetikzlibrary{intersections}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{backgrounds}
我发现了一个使用此代码来为三角形着色的网站。
\def\KurveI{(3,-.5) to (1.5,0)}
\def\KurveII{(.5,-.8) to (1.5,0)}
\def\KurveIII
{(.5,-.8) to (3,-.5)}
\draw \KurveI \KurveII \KurveIII
(current path bounding box.south west)coordinate(UL)
(current path bounding box.north east)coordinate(OR);
\begin{scope}[on background layer]
\clip (UL)--\KurveI--(UL-|OR)--cycle;% Fläche unterhalb der 1.Kurve
\clip (UL-|OR)--\KurveII--(OR)--cycle;% Fläche rechts von 2.Kurve
\clip (UL|-OR)--\KurveIII--(OR)--cycle;% Fläche oberhalb von 3.Kurve
\fill[yellow!50](UL)rectangle(OR);% Füllen der Schnittfläche
\end{scope}
但是,当我复制它时,它只会为三角形的一部分着色。有没有一个网站可以解释如何使用 tikz 为表面着色?或者我做错了什么?
以下是一些应该编译的代码。
\documentclass[12pt]{article}
\usepackage[ngerman]{babel}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}
\draw (3,-.5) to [<-, bend right=10] (1.5,0);
\draw (2,-1) to [<-, bend left=10] (.5,-.8);
\draw[dashed] (2,-1) -- (3,-.5) ;
\draw (.5,-.8) to (1.5,0);
\end{tikzpicture}
\begin{tikzpicture}
\def\KurveI{(3,-.5) to (1.5,0)}
\def\KurveII{(.5,-.8) to (1.5,0)}
\def\KurveIII
{(.5,-.8) to (3,-.5)}
\draw \KurveI \KurveII \KurveIII
(current path bounding box.south west)coordinate(UL)
(current path bounding box.north east)coordinate(OR);
\begin{scope}[on background layer]
\clip (UL)--\KurveI--(UL-|OR)--cycle;
\clip (UL-|OR)--\KurveII--(OR)--cycle;
\clip (UL|-OR)--\KurveIII--(OR)--cycle;
\fill[yellow!50](UL)rectangle(OR);
\end{scope}
\end{tikzpicture}
\end{document}
答案1
为了找到答案,我向您展示了如何填充形状。
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\fill[blue] (1.5,0) to[bend left=10] (3,-.5) to (2,-1) to [bend left=10] (.5,-.8) to cycle;
\draw (3,-.5) to [<-, bend right=10] (1.5,0) node[left]{};
\draw (2,-1) to [<-, bend left=10] (.5,-.8) node[left]{};
\draw[dashed] (2,-1) -- (3,-.5) node[left] {};
\draw (.5,-.8) to (1.5,0) node[left]{};
\end{tikzpicture}
\end{document}