顶点之间的阴影

顶点之间的阴影

我正在尝试为顶点 1-2-3 的各种三角形进行着色。

以下是我目前所掌握的信息:

\begin{center}
\begin{tikzpicture}[scale=4] %color=red
\SetVertexLabel
\tikzstyle{every node}=[thick,draw, shape=circle,scale=.5]; %fill=black,
\path (0:0cm) node (1) {1};
\path (-60:1.7cm) node (2) {2};
\path (240:1.7cm) node (3) {3};
\path (240:1cm) node (4) {3};
\path (240:.5cm) node (5) {3};
\path (240:1.4cm) node (6) {1};
\path (-60:.75cm) node (7) {2};
\path (-60:1.2cm) node (8) {1};
\path (280:1.499cm) node (9) {2};
\path (260:1.2cm) node (10) {1};
\path (280:.5cm) node (11) {2};
\path (279:1.1cm) node (12) {3};
\path (265:.8cm) node (13) {1};
\SetVertexLabel
\tikzstyle{every node}=[thick,draw, shape=circle,scale=.5,fill=red]
\path (245:1.4cm) node (14) {};
\path (246:1.17cm) node (15) {};
\path (248:.75cm) node (16) {};
\path (256:.3cm) node (17) {};
\path (262:.6cm) node (18) {};
\path (255:1cm) node (19) {};
\path (260:1.37cm) node (20) {};
\path (273:1.25cm) node (21) {};
\path (268:1cm) node (22) {};
\path (280:.87cm) node (23) {};
\path (281:.66cm) node (24) {};
\path (290:.4cm) node (25) {};
\path (293:1cm) node (26) {};
\path (295:1.35cm) node (27) {};
\path (287:1.4cm) node (28) {};
\path (-30:1cm) node (29) {};
\draw[black,very thick] (1) -- (7)
(2) -- (9)
(4) -- (6)
(5) -- (1)
(5) -- (4)
(3) -- (6)
(8) -- (2)
(9) -- (3)
(11) -- (1)
(11) -- (7)
(11) -- (5)
(11) -- (13)
(13) -- (5)
(13) -- (7)
(13) -- (4)
(10) -- (4)
(10) -- (6)
(13) -- (10)
(13) -- (12)
(10) -- (12)
(10) -- (3)
(10) -- (9)
(12) -- (9)
(12) -- (2)
(12) -- (7)
(8) -- (7)
(12) -- (8);
\draw[red,very thick]
(17) -- (25)
(18) -- (24)
(23) -- (24)
(25) -- (29)
(26) -- (29)
(27) -- (29)
(20) -- (21);
%\path[fill=green] (1) -- (5) -- (11) -- (1) -- cycle;
%\fill[color=green] (1) -- (5) -- (11) -- (1) -- cycle;
%\shadedraw[draw, fill=green!20] (1) -- (5) -- (11) -- (1) -- cycle;
\end{tikzpicture}
\end{center}

输出如下:

在此处输入图片描述

我尝试了代码底部的 %commands,但到目前为止它们还没有起作用。有办法吗?

答案1

我使用background图层填充了一些三角形。为了获得更好的效果,我还在fill=white每个顶点上添加了图层。

原始解决方案的问题在于您没有得到一个封闭的区域来填充。语法(1)--(3)--... 在节点的边界上停止线条。您需要明确指向它们的中心:(1.center)--(3.center)--...

\documentclass{article}
\usepackage{tkz-graph}
\usetikzlibrary{backgrounds}

\begin{document}
\begin{center}
\begin{tikzpicture}[scale=4] %color=red
\SetVertexLabel
\tikzstyle{every node}=[thick,draw, shape=circle,scale=.5, fill=white]; %fill=black,
\path (0:0cm) node (1) {1};
\path (-60:1.7cm) node (2) {2};
\path (240:1.7cm) node (3) {3};
\path (240:1cm) node (4) {3};
\path (240:.5cm) node (5) {3};
\path (240:1.4cm) node (6) {1};
\path (-60:.75cm) node (7) {2};
\path (-60:1.2cm) node (8) {1};
\path (280:1.499cm) node (9) {2};
\path (260:1.2cm) node (10) {1};
\path (280:.5cm) node (11) {2};
\path (279:1.1cm) node (12) {3};
\path (265:.8cm) node (13) {1};
\SetVertexLabel
\tikzstyle{every node}=[thick,draw, shape=circle,scale=.5,fill=red]
\path (245:1.4cm) node (14) {};
\path (246:1.17cm) node (15) {};
\path (248:.75cm) node (16) {};
\path (256:.3cm) node (17) {};
\path (262:.6cm) node (18) {};
\path (255:1cm) node (19) {};
\path (260:1.37cm) node (20) {};
\path (273:1.25cm) node (21) {};
\path (268:1cm) node (22) {};
\path (280:.87cm) node (23) {};
\path (281:.66cm) node (24) {};
\path (290:.4cm) node (25) {};
\path (293:1cm) node (26) {};
\path (295:1.35cm) node (27) {};
\path (287:1.4cm) node (28) {};
\path (-30:1cm) node (29) {};
\draw[black,very thick] (1) -- (7)
(2) -- (9)
(4) -- (6)
(5) -- (1)
(5) -- (4)
(3) -- (6)
(8) -- (2)
(9) -- (3)
(11) -- (1)
(11) -- (7)
(11) -- (5)
(11) -- (13)
(13) -- (5)
(13) -- (7)
(13) -- (4)
(10) -- (4)
(10) -- (6)
(13) -- (10)
(13) -- (12)
(10) -- (12)
(10) -- (3)
(10) -- (9)
(12) -- (9)
(12) -- (2)
(12) -- (7)
(8) -- (7)
(12) -- (8);
\draw[red,very thick]
(17) -- (25)
(18) -- (24)
(23) -- (24)
(25) -- (29)
(26) -- (29)
(27) -- (29)
(20) -- (21);
\begin{scope}[on background layer]
\path[fill=green] (1.center) -- (5.center) -- (11.center) -- cycle;
\path[fill=blue!50] (5.center) -- (11.center) -- (13.center) -- cycle;
\end{scope}
%\fill[color=green] (1) -- (5) -- (11) -- (1) -- cycle;
%\shadedraw[draw, fill=green!20] (1) -- (5) -- (11) -- (1) -- cycle;
\end{tikzpicture}
\end{center}
\end{document}

在此处输入图片描述

相关内容