Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
a curve, an area, or something special? –  Herbert Jan 11 '11 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. –  xport Jan 11 '11 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? –  Juan A. Navarro Jan 11 '11 at 15:19
    
@Juan: It is possible but I want to use the mechanism the PSTricks authors use. –  xport Jan 11 '11 at 16:39

1 Answer 1

up vote 2 down vote accepted
\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

share|improve this answer
    
Is there a counterpart of \begin@ClosedObj ? Is it \begin@OpenObj ? –  xport Jan 11 '11 at 16:03
    
@xport: yes, that one can have line ends like arrows. And we have \begin@SpecialObj for special purposes. –  Herbert Jan 11 '11 at 16:08
    
Is there a free documentation on the web explaining how to use these macros? –  xport Jan 11 '11 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). –  Herbert Jan 11 '11 at 16:43
    
thanks for the link. –  xport Jan 11 '11 at 17:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.