I don't have much experience with creating new symbols using the \pgfdeclareshape macro, and I believe there are a few things I'm overlooking.
My specific question is: Why the line associated with the tikz \draw operation is not obscured by the symbol when placed on a path? For instance, in many examples of the circuits library documentation, resistors are clearly not drawn with a line extending through the center of the symbol.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\usetikzlibrary{circuits}
\begin{document}
\makeatletter
\pgfdeclareshape{symbol shape}
{
\anchor{center}{\pgfpointorigin}
\backgroundpath{%
\pgfpathmoveto{\pgfpoint{-2cm}{-0.5cm}}
\pgfpathlineto{\pgfpoint{-2cm}{0.5cm}}
\pgfpathlineto{\pgfpoint{2cm}{0.5cm}}
\pgfpathlineto{\pgfpoint{2cm}{-0.5cm}}
\pgfpathlineto{\pgfpoint{-2cm}{-0.5cm}}
\pgfpathmoveto{\pgfpoint{-2cm}{-0.5cm}}
\pgfpathlineto{\pgfpoint{2cm}{0.5cm}}
\pgfpathmoveto{\pgfpoint{-2cm}{0.5cm}}
\pgfpathlineto{\pgfpoint{2cm}{-0.5cm}}
\pgfusepath{stroke}
}
}
\makeatother
\begin{tikzpicture}[
circuit,
circuit declare symbol=symbol,
set symbol graphic={shape=symbol shape, draw, minimum size=1cm,transform shape}
]
\draw (0,0) to [symbol] (8,0);
\end{tikzpicture}
\end{document}
Can anyone suggest an improvement to the code shown above in order to prevent the \draw operation line from extending through the symbol?
