# Polygon with balls as corners

I would like to draw a regular polygon with tikz. It should be something like this but i want the dots to be balls like \shade[ball color=black].

Another problem I have is that I cannot run the code in the link in the \documentclass{scrreprt}. Coud you help me out?

tech

• You can definitely run the code in Henri Menke's answer in scrreprt, I just tested, but you need of course to add \usepackage{tikz}. If that doesn't fix it, then we really need some more information about your setup and what happens when you run the code (which error is reported). – Torbjørn T. Oct 8 '15 at 12:15

This example draws a regular n-gon. Change the 8 in \def\n{8} to select the number of edges.

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

\def\n{8}
\foreach \i in {1, ..., \n}{
\node[circle, shade, ball color=black, outer sep=0pt, inner sep=2pt] (ball\i) at (\i*360/\n:1) {};
}
\foreach \i[remember=\i as \lasti (initially \n)] in {1, ..., \n}{
\draw (ball\lasti) -- (ball\i);
}

\end{tikzpicture}
\end{document}


With Alain Matthes tkz-berge, it's easy to do it:

\documentclass[border=2mm, tikz]{standalone}
\usepackage{tkz-berge}

\begin{document}
\begin{tikzpicture}
\SetVertexNoLabel
\grCirculant[RA=3]{8}{1}%
\end{tikzpicture}
\end{document}


A solution with PSTricks. curvepnodes is useful to define an array of nodes for any given number of nodes and curve functions. For example, we can use it to make an array of 12 nodes on a circle. Offset is provided as the rotation offset.

\documentclass[pstricks,margin=5mm]{standalone}
\usepackage{pst-node,pst-plot}

\begin{document}
\multido{\i=0+10}{10}{%
\begin{pspicture}[showpoints,dotscale=6](-4,-4)(4,4)
\pstVerb{/Offset \i\space def}%