# Automatically framing (or drawing the bounding box of ) a PStricks non-text object

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.

-
In your title you mention "graphic", while your post refers to "object". These can be interpreted differently. Therefore, does "object" refer to the entire contents of your pspicture, or merely an object like some text? –  Werner Sep 28 '11 at 6:06
I've changed graphic to non-text graphic, for example a circle of radius 2 i.e. \pscircle(5,5){2} –  Olumide Sep 28 '11 at 6:15
You should create complete examples, then everybods knows what exactly you are asking for –  Herbert Sep 28 '11 at 6:37

## 1 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}


-
The framebox is tiny and at the origin. Here's what I tried \psframebox[shadow]{\pscircle(5,5){2}} –  Olumide Sep 28 '11 at 6:38
sure, as I wrote: If you'd provide a complete example then it is possible to give a correct answer. See my edit. –  Herbert Sep 28 '11 at 6:59
I apologize. I realize that I haven't made myself clear enough. I was hoping for a command that could automatically frame an object, without having to specify its dimensions. The problem I'm having is in computing the dimensions of the frame, for my objects some of who undergo transformations such as rotation. –  Olumide Sep 28 '11 at 11:36
@Olumide: It is pretty simple, but only when I know what exactly you want. And now I know it, see edited answer –  Herbert Sep 28 '11 at 12:15
Thanks @Herbert ("You da man"). I'll try generalizing the macro for arbitrary objects. –  Olumide Sep 28 '11 at 14:03