如何将正十二边形端点的样式从圆点改为正方形?

如何将正十二边形端点的样式从圆点改为正方形?

我想画一个有12个顶点的圆,圆的样式是规则的12边形,因此我使用以下代码:

\documentclass[tikz, border=1mm]{standalone}
\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{tikzpicture}
  \node[regular polygon, regular polygon sides=12, draw, minimum size=6cm] 
  (outer_poly) {};
  \foreach \n in {1,...,12}
  {
    \fill (outer_poly.corner \n) circle (5pt)  {};
  }
\end{tikzpicture}
\end{document}

我想将奇数索引的顶点更改为正方形,但我不知道如何更改。

\documentclass[tikz, border=1mm]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
  \tikzset{bluenode/.style={fill=blue, draw=blue, shape=rectangle, minimum 
  size=0.15cm, inner sep=4pt}};
  \node[regular polygon, regular polygon sides=12, draw, minimum size=3cm] 
  (outer_poly)  {};
  \foreach \i in {1,...,12}
  {
     \ifodd\i % test if i odd or even 
            \fill (outer_poly.corner \i) circle (2pt); % I want to change the style of bluenode!
        \else          
            \fill (outer_poly.corner \i) circle (2pt);
        \fi
    }
\end{tikzpicture}
\end{document}
 

我想按照以下样式来绘制它:

![在此处输入图片描述

答案1

例如,有几种样式:

\documentclass[tikz, border=1mm]{standalone}
\usetikzlibrary{shapes.geometric}

\tikzset
{
  node 0/.style={minimum size=5pt,circle,fill=black},
  node 1/.style={minimum size=5pt,rectangle,fill=blue},
}

\begin{document}
\begin{tikzpicture}
  \node[regular polygon, regular polygon sides=12, draw, minimum size=6cm] 
  (outer_poly) {};
  \foreach \n in {1,...,12}
     \pgfmathtruncatemacro\i{mod(\n,2)}
     \node[node \i] at (outer_poly.corner \n) {};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容