I'm struggling to get my head around the pgfkeys
package. I currently use the keycommand
package, which I find very easy to understand: it's just ordinary LaTeX commands with named rather than numbered arguments. However, I would like to use pgfkeys
because my project is heavily based on TikZ, and I believe it is a more powerful solution. I think understanding how to translate the following little example from keycommand
to pgfkeys
would help me a lot.
Example
I make a command to draw a doublecircle
gadget. It has two arguments: diameter
and color
, both optional, with default values 1
and red
respectively.
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage{keycommand}
\newcounter{currentheight}
\setcounter{currentheight}{0}
\newkeycommand{\doublecircle}[diameter=1,color=red]{%
\fill[\commandkey{color}] (0,\thecurrentheight) circle (\commandkey{diameter}/2);
\fill[\commandkey{color}] (\commandkey{diameter}/2,\thecurrentheight) circle (\commandkey{diameter}/2);
}
\begin{document}
\begin{tikzpicture}[y=-1cm]
\doublecircle[color=blue]
\addtocounter{currentheight}{5}
\doublecircle[diameter=4]
\addtocounter{currentheight}{6}
\doublecircle[diameter=3,color=green]
\end{tikzpicture}
\end{document}
pgfkeys
implementation needs an equivalentadd to height
key?\newcommand{\currentheight}{0}
.