3

Scenario

I want to create a new PSTricks object, e.g., \myBatLogo[<key-val options>]{}{}...{} that is not a redefinition of a built-in PSTricks object.

It means that any redefinition as follows does not make sense in my scenario.

\newpsobject{myBatLogo}{<built-in PSTrick object>}

Question

How to define a new PSTrick object that is not a redefinition of a built-in PSTricks object? It must accept key-value optional arguments and mandatory arguments.

4
  • a curve, an area, or something special?
    – user2478
    Commented Jan 11, 2011 at 14:26
  • @Herbert: for simplicity, let the new object just draw BATMAN logo with fillcolor as an optional argument and the center bounding box position {x,y} as the mandatory argument. Commented Jan 11, 2011 at 14:36
  • I have no idea about PSTricks, but can't you simply define a macro (maybe using keyval for the optional arguments) that expands to the code to draw the object using built-in PSTrick objects? Commented Jan 11, 2011 at 15:19
  • @Juan: It is possible but I want to use the mechanism the PSTricks authors use. Commented Jan 11, 2011 at 16:39

1 Answer 1

2
\documentclass{article}
\usepackage{pstricks}
\makeatletter
\def\psBatman{\pst@object{psBatman}}
\def\psBatman@i(#1)#2{%
  \begin@ClosedObj%
  \rput(#1){\psframebox{#2}}
  \end@ClosedObj%
}
\makeatother

\begin{document}
\pspicture(7,7)
\psBatman(1,1){Batman}
\psBatman[fillcolor=red!50,shadow=true,framesep=20pt,framearc=0.3](3,4){\Huge Me}
\psBatman*[linecolor=blue!20,framesep=20pt](6,6){\huge you}
\endpspicture
\end{document}

alt text

4
  • Is there a counterpart of \begin@ClosedObj ? Is it \begin@OpenObj ? Commented Jan 11, 2011 at 16:03
  • @xport: yes, that one can have line ends like arrows. And we have \begin@SpecialObj for special purposes.
    – user2478
    Commented Jan 11, 2011 at 16:08
  • Is there a free documentation on the web explaining how to use these macros? Commented Jan 11, 2011 at 16:37
  • @xport: sure mirror.ctan.org/graphics/pstricks/base/doc/pstricks-doc.pdf. pp 163 for high level objects (without using PostScript code) and pp 171 for low level objects (coordinate transformation and using PostScript code).
    – user2478
    Commented Jan 11, 2011 at 16:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .