可以为这个标志的‘内部’区域着色吗?
\documentclass{scrartcl}
\usepackage[german]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{bera}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usepackage{makecell}
\tikzset
{
shadeball/.style={circle,shading=ball, minimum size=0.6cm},
utedge/.style={->,ultra thick}
}
\begin{document}
\begin{tikzpicture}
\draw (0,0) rectangle (14,3);
\node at (1.8,2.3) {\Huge\textbf{\textsf{my\LaTeX}}};
\node at (10.6,0.8) {\LARGE\makecell[r]{line1 line1 line1 line1 li\\line2 line2 line2 line}};
\node[shadeball, ball color=LawnGreen] (b1) at (5.7,0.85) {};
\node[shadeball, ball color=Fuchsia] (b2) at (10.7,2.15) {};
\node[shadeball, ball color=Cyan] (b3) at (4.7,2.25) {};
\node[shadeball, ball color=Gold] (b4) at (2.1,0.55) {};
\node[shadeball, ball color=Tomato] (b5) at (0.7,1.65) {};
\node[shadeball, ball color=Chocolate] (b6) at (7.7,0.45) {};
\draw[utedge] (b2) to [bend right=20] (b1);
\draw[utedge] (b3) to [bend left=30] (b1);
\draw[utedge] (b4) to [bend right=10] (b1);
\draw[utedge] (b4) to [bend right=30] (b3);
\draw[utedge] (b3) to [bend left=20] (b2);
\draw[utedge] (b5) to [bend right=30] (b4);
\draw[utedge] (b5) to [bend right=20] (b3);
\draw[utedge] (b1) to [bend right=30] (b6);
\end{tikzpicture}
\end{document}
答案1
这里,由于您的节点是半径为 3 毫米的圆,因此您可以通过缩短曲线链接节点的中心,而不是链接两个节点。
\documentclass{standalone}
\usepackage[T1]{fontenc}
\usepackage{bera}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\tikzset{
shadeball/.style={circle,shading=ball, minimum size=0.6cm},
utedge/.style={->,ultra thick,shorten >=3mm,shorten <=3mm}
}
\begin{document}
\begin{tikzpicture}
\node[font=\bfseries\Huge\sffamily] at (1.8,2.3) {my\LaTeX};
\node[align=right,font=\LARGE] at (10.6,0.8)
{line1 line1 line1 line1 li\\line2 line2 line2 line};
\node[shadeball, ball color=LawnGreen] (b1) at (5.7,0.85) {};
\node[shadeball, ball color=Fuchsia] (b2) at (10.7,2.15) {};
\node[shadeball, ball color=Cyan] (b3) at (4.7,2.25) {};
\node[shadeball, ball color=Gold] (b4) at (2.1,0.55) {};
\node[shadeball, ball color=Tomato] (b5) at (0.7,1.65) {};
\node[shadeball, ball color=Chocolate] (b6) at (7.7,0.45) {};
\begin{pgfonlayer}{background}
\fill[red!50] (b1.center) to[bend left=20] (b2.center)
to[bend right=20] (b3.center) to[bend left=30] (b1.center);
\fill[cyan!50] (b1.center) to[bend left=10] (b4.center)
to[bend right=30] (b3.center) to[bend left=30] (b1.center);
\fill[orange!50] (b5.center) to[bend right=30] (b4.center)
to[bend right=30] (b3.center) to[bend left=20] (b5.center);
\end{pgfonlayer}
\draw[utedge] (b2.center) to [bend right=20] (b1.center);
\draw[utedge] (b3.center) to [bend left=30] (b1.center);
\draw[utedge] (b4.center) to [bend right=10] (b1.center);
\draw[utedge] (b4.center) to [bend right=30] (b3.center);
\draw[utedge] (b3.center) to [bend left=20] (b2.center);
\draw[utedge] (b5.center) to [bend right=30] (b4.center);
\draw[utedge] (b5.center) to [bend right=20] (b3.center);
\draw[utedge] (b1.center) to [bend right=30] (b6.center);
\end{tikzpicture}
\end{document}
答案2
我发现这确实有点棘手。很难用给定的路径填充或裁剪,因为它们不是封闭的,并且修改它们以通过节点中心并形成封闭路径会改变曲线。使用 连接路径to
,--
如下所示:
\clip (b5) to [bend right=20] (b3) -- (b3) to[bend left=30] (b4) -- (b4) to[bend left=30] (b5);
也不起作用,原因我不明白。它看起来像这样:
您可以通过将曲线与曲线落在节点边界上的点之间的线段连接起来,从而得到闭合路径。获取这些坐标就像coordinate
在路径上进行操作一样简单!
\documentclass{scrartcl}
\usepackage{bera}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{makecell}
\tikzset
{
shadeball/.style={circle,shading=ball, minimum size=6mm},
utedge/.style={->,ultra thick},
}
\begin{document}
\begin{tikzpicture}
\draw (0,0) rectangle (14,3);
\node at (1.8,2.3) {\Huge\textbf{\textsf{my\LaTeX}}};
\node at (10.6,0.8) {\LARGE\makecell[r]{line1 line1 line1 line1 li\\line2 line2 line2 line}};
\node[shadeball, ball color=LawnGreen] (b1) at (5.7,0.85) {};
\node[shadeball, ball color=Fuchsia] (b2) at (10.7,2.15) {};
\node[shadeball, ball color=Cyan] (b3) at (4.7,2.25) {};
\node[shadeball, ball color=Gold] (b4) at (2.1,0.55) {};
\node[shadeball, ball color=Tomato] (b5) at (0.7,1.65) {};
\node[shadeball, ball color=Chocolate] (b6) at (7.7,0.45) {};
\draw[utedge] (b2) to [bend right=20] coordinate[at start] (b21) (b1) coordinate (b12);
\draw[utedge] (b3) to [bend left=30] coordinate[at start] (b31) (b1) coordinate (b13);
\draw[utedge] (b4) to [bend right=10] coordinate[at start] (b41) (b1) coordinate (b14);
\draw[utedge] (b4) to [bend right=30] coordinate[at start] (b43) (b3) coordinate (b34);
\draw[utedge] (b3) to [bend left=20] coordinate[at start] (b32) (b2) coordinate (b23);
\draw[utedge] (b5) to [bend right=30] coordinate[at start] (b54) (b4) coordinate (b45);
\draw[utedge] (b5) to [bend right=20] coordinate[at start] (b53) (b3) coordinate (b35);
\draw[utedge] (b1) to [bend right=30] coordinate[at start] (b16) (b6) coordinate (b61);
\begin{scope}[on background layer]
\fill[orange!60] (b54) to [bend right=30] (b45) --
(b43) to [bend right=30] (b34) --
(b35) to [bend left=20] (b53) -- cycle;
\fill[purple!60] (b43) to [bend right=30] (b34) --
(b31) to [bend left=30] (b13) --
(b14) to [bend left=10] (b41) -- cycle;
\fill[green!60] (b32) to [bend left=20] (b23) --
(b21) to [bend right=20] (b12) --
(b13) to [bend right=30] (b31) -- cycle;
\end{scope}
\end{tikzpicture}
\end{document}
请注意,我使用了backgrounds
TikZ 库。
这比我之前删除的方法好得多。请参阅编辑历史,了解重叠每条曲线的剪切区域的方法。