Please can I use node inside pgfonlayer? The node in question is commented out in the following:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{scopes}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}
[
my line/.style={line width=2.5pt},
put circle/.style={circle,draw=blue!50,fill=blue!20,thick,
inner sep=0pt,minimum size=5mm},
execute at end picture={
\begin{pgfonlayer}{background}
\path[fill=yellow!25,rounded corners,my line,draw=red]
(current bounding box.south west) rectangle
(current bounding box.north east);
%\node at (2,2) [my line] {
{
[magenta]
\draw (0mm,10mm) -- (15mm,10mm);
\draw (0mm,8mm) -- (15mm,8mm);
}
\draw (0mm,6mm) -- (15mm,6mm);
{
[green]
\draw (0mm,4mm) -- (15mm,4mm);
\draw (0mm,2mm) -- (15mm,2mm);
\draw[blue] (0mm,0mm) -- (15mm,0mm);
};
%};
\end{pgfonlayer}
}
]
\node at (0,0) [put circle] {X};
\node at (4,1) [put circle] {Y};
\end{tikzpicture}
\end{document}

tikzpicture) won't work (IIRC TikZ undefines its commands inside the node text). – Caramdir Jun 17 '12 at 5:34