如何在 tikzpicture 中对扇区的部分进行着色

如何在 tikzpicture 中对扇区的部分进行着色

您能告诉我如何修改下面的代码,以便我可以为六边形周围的部分添加阴影吗(附图)?

非常感谢

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\renewcommand{\thesection}{\arabic{section}}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{pgfplots}
\usepackage{amsmath}
\newtheorem{theorem}{THEOREM}
\newtheorem{proof}{PROOF}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{patterns}
\usepackage{fancyhdr}
\usepackage{bigints}
\usepackage{color}
\usepackage{tcolorbox}
\usepackage{color,xcolor}
\usepackage{booktabs,array}
\usepackage{hyperref}
\usepackage{graphicx}
\usetikzlibrary{arrows}
\usepackage{polynom}
\usepackage{wallpaper}
\usepgfplotslibrary{fillbetween}
\newenvironment{tightcenter}{
\setlength\topsep{0pt}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
\begin{tikzpicture}
\newdimen\R
\R=1.7cm
\draw[thick] (0:\R)
\foreach \x in {60,120,...,360} {  -- (\x:\R) }
-- cycle (360:\R)
-- cycle (300:\R)
-- cycle (240:\R)
-- cycle (180:\R)
-- cycle  (120:\R)
-- cycle  (60:\R);
\fill[black,thick] (0,0) circle (0.4mm);
\draw[black,thick] (0,0) circle (1.7cm);
\draw [thick](0,0) -- (+0.84,1.48);
\draw [thick](0,0) -- (-0.84,1.48);
%\draw [thick](0,0) -- (+2.08,0);
%\draw [thick](0,0) -- (-2.08,0);
%\draw [thick](0,0) -- (+1.05,-1.8);
%\draw [thick](0,0) -- (-1.05,-1.8);
%\draw [thick,<->] (0+0.78,0) -- node[fill=white]{$1.6$ cm} (1.05+0.78,1.8);
\node[above,scale=0.9] at (0,0.4) {$60^{\circ}$};
\end{tikzpicture}
\end{document}

期望输出

答案1

你可以使用even odd rule它。我还删除了所有不必要的包和行。

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\newdimen\R
\R=1.7cm
\draw[thick] (0:\R)
\foreach \x in {60,120,...,360} {  -- (\x:\R) };
\fill[black,thick] (0,0) circle (0.4mm);
\draw[black,thick] (0,0) circle (1.7cm);
\fill[yellow,even odd rule] (0:\R)
\foreach \x in {60,120,...,360} {  -- (\x:\R) }  (0,0) circle (1.7cm);
\draw [thick](0,0) -- (+0.84,1.48);
\draw [thick](0,0) -- (-0.84,1.48);
\node[above,scale=0.9] at (0,0.4) {$60^{\circ}$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

只是为了完整性:与 的输出相同shapes.geometric

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
\newdimen\R
\R=1.7cm
\node[regular polygon, regular polygon sides=6, draw,thick,
 minimum width={2*\R}] (hexagon)  {};
\fill[black,thick] (0,0) circle (0.4mm);
\draw[black,thick] (0,0) circle (1.7cm);
\fill[yellow,even odd rule] (0:\R)
\foreach \X in {1,...,6} {  -- (hexagon.corner \X) }  (0,0) circle (1.7cm);
\draw [thick] (hexagon.corner 1) -- (0,0) -- (hexagon.corner 2);
\node[above,scale=0.9] at (0,0.4) {$60^{\circ}$};
\end{tikzpicture}
\end{document}

相关内容