[Tex/LaTex] Automatically framing (or drawing the bounding box of ) a PStricks non-text object

framedpstricks

Is there a command or macro that can draw and automatically size the bounding rectangle of a pstricks object, for example a circle — framing it tightly in effect, even when the object undergoes transformations such as rotations.

For example,

     \documentclass[english, landscape, a4paper]{slides}
     \usepackage{pstricks}

    \begin{pspicture}(1,-1)(20,17) 
        \pscircle(5,5){2} % I'd like to draw the bounding box of this object
    \end{pspicture}

Edit: the difficulty that I'm having is calculating the dimensions of the frame or bounding box.

Best Answer

\psframebox[shadow,framesep=...,...]{%
  pstricks object with a pspicture environment
}

or if you do not have it outside of the pspicture environment

\documentclass[english, landscape, a4paper]{slides}
\usepackage{pstricks} \SpecialCoor
\makeatletter
\def\psCircleSquare{\pst@object{psCircleSquare}}
\def\psCircleSquare@i(#1)#2{{%
  \use@par
  \rput(#1){\psframe(!#2 neg dup)(!#2 dup)}%
  \pscircle(#1){#2}%
}}
\makeatother

\begin{document}

\psset{unit=0.5}
\begin{pspicture}(1,-1)(20,17) 
  \psCircleSquare[shadow](5,5){2} 
\end{pspicture}

\end{document}

enter image description here