[Tex/LaTex] PGF custom shapes and regular polygons

tikz-pgf

TikZ allows regular polygons with specified number of sides for nodes. I'm using PGF though and want similar features and to be able to create my own custom shapes.

See percusse's answer for example code:

Tikz scale vs pgf scale

and

http://www.texample.net/tikz/examples/node-shapes/

for the polygons.

What I would like is to be able to create a reference shape like rpoly7 that is simply a regular polygon with 7 sides that uses the TikZ shapes but can be passed to PGF like I do with the other shapes.

Best Answer

The regular polygon shape is not a "TikZ shape" (and neither are any of the other predefined shapes), they're all "PGF shapes". General rule: If the relevant keys in the pgfmanual include the /pgf directory, they're PGF keys. To set the parameters like regular polygon sides, you have to call \pgfkeys{/pgf/<option>=<value}:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{tikzpicture}
\pgfkeys{/pgf/regular polygon sides=6,/pgf/minimum size=0.75cm}
\pgfnode{regular polygon}{center}{}{}{}
\pgfusepath{draw}
\pgftransformshift{\pgfpoint{1cm}{0pt}}
\pgfkeys{/pgf/regular polygon sides=3}
\pgfnode{regular polygon}{center}{}{}{}
\pgfusepath{draw}
\end{tikzpicture}
\end{document}