[pstricks] Newbie question on how to create an own object
Herbert Voss
LaTeX at zedat.fu-berlin.de
Sun Dec 3 09:48:00 CET 2006
Seweryn Kokot schrieb:
> Well the syntax is not newbie friendly. I can figure out how the above example
but it is nearly self-explanatory ....
> works but what if I specify (x,y) and the other object must be calulated based
> on these (x,y) coordinates?
everything is mentioned in the docs
> For example:
> http://img56.imageshack.us/my.php?image=ownobjectat7.png
> How to draw the horizontal line with ends at (x-2,y-2) and (x+2,y-2) based on
> specified (x,y)? And how to specify a rotation and the mirror image with
> regards the axis x in options?
\documentclass[a4paper,12pt]{article}
\usepackage{multido,pstricks,pst-xkey}
\SpecialCoor
\makeatletter
\def\psImage{\@ifnextchar[{\psImage at i}{\psImage at i[]}}
\def\psImage at i[#1](#2,#3){{%
\pst at killglue%
\psset{#1}
\psdots(!#2 2 sub #3 2 sub)(#2,#3)(!#2 2 add #3 2 sub)
\psline(!#2 2 sub #3 2 sub)(!#2 2 add #3 2 sub)
\psline(!#2 3 sqrt 2 div sub #3 2 sub)(#2,#3)(!#2 3 sqrt 2 div add #3
2 sub)
\multido{\iA=-2+1}{4}{%
\psline(!#2 \iA\space add #3 4 sub)(!#2 \iA\space 1 add add #3 2
sub)}
}\ignorespaces}
\makeatother
\begin{document}
\psImage[linecolor=red,linewidth=2pt](4,4)
\vspace{4cm}
\psImage[linecolor=blue,dotscale=1.5](4,4)
\end{document}
Hebrert
More information about the PSTricks
mailing list