下面的代码
\begin{tikzpicture}
\draw[clip] (0,0) circle (3cm);
\foreach \a in {120,250,310}
{
\draw (-1,.5) -- (\a:4cm);
}
\end{tikzpicture}
将分区集划分为三个大小各异的子集:
第一个问题是:如何用不同的颜色填充这三个不同的区域?我尝试过:
\begin{tikzpicture}
\draw[clip] (0,0) circle (3cm);
\foreach \a in {120,250,310}
{
\draw[pattern=north east lines,pattern color=red] (-1,.5) -- (\a:4cm);
}
\end{tikzpicture}
但我仍然得到了相同的数字。
此外,我想用曲线代替用于分区的三条直线。然后我使用了:
\begin{tikzpicture}
\draw[clip] (0,0) circle (3cm);
\foreach \a in {120,250,310}
{
\draw (-1,.5) to[out=135, in=315] (\a:4cm);
}
\end{tikzpicture}
但我得到了:
这三条曲线的交点似乎有问题。
答案1
经过一些测试,我得到了这个:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{hobby}
\begin{document}
\begin{tikzpicture}
\draw[fill=red!30] circle (3cm);
\draw[fill=blue!30] (160:3cm)-- (160:2cm) to [curve through={(159:1cm) (30:0.5cm)}] (35:3cm) arc (35:160:3cm)--cycle;
\draw[fill=green] (160:3cm)-- (160:2cm) to [curve through={(165:1cm) (270:0.5cm)}] (275:3cm) arc (275:160:3cm)--cycle;
\end{tikzpicture}
\end{document}
我知道它们不是曲线,但它们看起来像曲线;-)
答案2
您不需要任何剪辑来实现这一点,但您必须小心您的in and out
s。
\documentclass[tikz,border=3.14pt]{standalone}
\begin{document}
\begin{tikzpicture}
\def\r{3}
\coordinate (A) at (-1,.5);
\fill[cyan] (A) to [out=135,in=45] (250:\r cm) arc (250:120:\r) to [out=-110,in=135] (A) ;
\fill[orange] (A) to [out=135,in=45] (250:\r cm) arc (250:310:\r) to [out=135,in=-45] (A) ;
\fill[pink] (A) to [out=-45,in=135] (310:\r cm) arc (-50:120:\r) to [out=-110,in=135] (A) ;
%\draw[red] (0,0) circle (3cm);
\end{tikzpicture}
\end{document}
参数稍有变化:
\documentclass[tikz,border=3.14pt]{standalone}
\begin{document}
\begin{tikzpicture}
\def\r{3}
\coordinate (A) at (-1,.5);
\fill[cyan] (A) to [out=135,in=45] (250:\r cm) arc (250:120:\r) to [out=-110,in=135] (A) ;
\fill[orange] (A) to [out=135,in=45] (250:\r cm) arc (250:310:\r) to [out=90,in=-45] (A) ;
\fill[pink] (A) to [out=-45,in=90] (310:\r cm) arc (-50:120:\r) to [out=-110,in=135] (A) ;
%\draw[red] (0,0) circle (3cm);
\end{tikzpicture}
\end{document}
编辑
只是为了让您知道,不需要剪辑,也没有在另一个形状上绘制任何形状,这是一个破碎的图形。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def\r{3}
\coordinate (A) at (-1,.5);
\begin{scope}[transform canvas={xshift=-10pt}]
\fill[cyan] (A) to [out=135,in=45] (250:\r cm) arc (250:120:\r) to [out=-110,in=135] (A) ;
\end{scope}
\
begin{scope}[transform canvas={yshift=-10pt}]
\fill[orange] (A) to [out=135,in=45] (250:\r cm) arc (250:310:\r) to [out=90,in=-45] (A) ;
\end{scope}
\begin{scope}[transform canvas={xshift=5pt,yshift=5pt}]
\fill[pink] (A) to [out=-45,in=90] (310:\r cm) arc (-50:120:\r) to [out=-110,in=135] (A) ;
\end{scope}
\end{tikzpicture}
\end{document}
答案3
早期反应
\begin{tikzpicture}
\draw[clip] (0,0) circle (3cm);
\draw[pattern=north east lines,pattern color=red] (-1,.5) coordinate(a)-- (120:4cm) arc (120:60:4cm) -- (a);
\draw[pattern=north west lines,pattern color=blue] (-1,.5) coordinate(a)-- (60:4cm) arc (60:-130:4cm) -- (a);
\draw[pattern=vertical lines,pattern color=purple] (-1,.5) coordinate(a)-- (-130:4cm) arc (-130:-240:4cm) -- (a);
\end{tikzpicture}