PSTricks arrowheads

Denis Girou Denis.Girou at idris.fr
Fri Jul 30 22:39:57 CEST 1999


-----------------------------------------------------------------------------
This is the PSTricks mailing list, devoted to discussions about computational
graphics in (La)TeX using the PSTricks package from Timothy van Zandt.
For help using this mailing list, see instructions at the end of message.
-----------------------------------------------------------------------------

The following message is a courtesy copy of an article
that has been posted to comp.text.tex as well.

>>>>> "Torben.Hoffmann" == Torben Hoffmann <toho at it.dtu.dk> writes:

    Torben.Hoffmann> Hi there,
    Torben.Hoffmann> I would like to know how I can get arrowheads in PSTricks which are
    Torben.Hoffmann> _not_ filled  out as the default ones, ie, I want a triangle that is
    Torben.Hoffmann> white inside!

    Torben.Hoffmann> I have looked at the code in the 'pstricks.tex' file as well as finding
    Torben.Hoffmann> a message about how to make new arrowheads on the PSTricks mailing list,
    Torben.Hoffmann> but I cannot help thinging that someone has done this allready.

  This is not a functionality provided by PSTricks, which define only solid
arrows, but basically this is only a one line change (in the PostScript macro 
Arrow from pstricks.pro).

  Nevertheless there is a pitfall, because the current linewidth must be restored,
as it is temporary modified by a scaling mechanism during arrow drawing. It is 
also better to add a new parameter ("arrowfill" here) to choice between
filling or no filling, and to manage also double arrows (this require some
changes in their respective definitions).

  Here is a solution, but I do not test it extensively, so you must verify
that it has no side effect when using it in a more general context.

\documentclass[a4paper]{article}

\usepackage{pstricks}

% "arrowfill" parameter defined, to implement no filled arrows - D.G. (07/29/99)
\makeatletter

% Redefininition of \psset at arrowscale to store value of X scale factor
\def\psset at arrowscale#1{%
% D.G. modification begin - Jul. 29, 1999
\psset at arrowscale@i#1 \@nil
% D.G. modification end
\pst at getscale{#1}\psk at arrowscale}

\def\psset at arrowscale@i#1 #2\@nil{\edef\pst at arrowscale{#1}}

% Initialization of \pst at arrowscale with "arrowscale" default value (1)
\def\pst at arrowscale{1}

% New parameter "arrowfill", with default as "true"
\newif\ifpsarrowfill
\def\psset at arrowfill#1{\@nameuse{psarrowfill#1}}
\psset at arrowfill{true}

% Modification of the PostScript macro Arrow to choose to fill or not the arrow
% (it require to restore the current linewidth, despite of the scaling)
\pst at def{Arrow}<{%
CLW mul add dup 2 div
/w ED mul dup
/h ED mul
/a ED
{ 0 h T 1 -1 scale } if
% D.G. modification begin - Jul. 29, 1999
gsave
\ifpsarrowfill
\else
  \pst at number\pslinewidth \pst at arrowscale\space div SLW
\fi
% D.G. modification end
w neg h moveto
0 0 L w h L w neg a neg rlineto
% D.G. modification begin - Jul. 29, 1999
% gsave fill grestore
\ifpsarrowfill
  gsave fill grestore
\else
  gsave closepath stroke grestore
\fi
grestore
0 h a sub moveto
% D.G. modification end
}>

\@namedef{psas@>>}{%
false \psk at arrowinset \psk at arrowlength \psk at arrowsize \tx at Arrow
% D.G. modification begin - Jul. 30, 1999
% We suppress also the gap between the two arrows
% 0 h T
0 h a sub T
% D.G. modification end
gsave
newpath
false \psk at arrowinset \psk at arrowlength \psk at arrowsize \tx at Arrow
CP
grestore
% D.G. modification begin - Jul. 30, 1999
% CP newpath moveto 2 copy L stroke
% D.G. modification end
moveto
}

\@namedef{psas@<<}{%
true \psk at arrowinset \psk at arrowlength \psk at arrowsize \tx at Arrow
% D.G. modification begin - Jul. 30, 1999
% We suppress also the gap between the two arrows
% CP newpath moveto 0 a neg L stroke 0 h neg T
0 h neg a add T
% D.G. modification end
false \psk at arrowinset \psk at arrowlength \psk at arrowsize \tx at Arrow
% D.G. modification begin - Jul. 30, 1999
0 h a 5 mul 2 div sub moveto
% D.G. modification end
}

\makeatother

\pagestyle{empty}

\begin{document}

\psset{subgriddiv=0,arrowscale=3}

\begin{pspicture}(3,3)\psgrid
  \psline{->}(2,2)
  \parabola[linestyle=dotted,linecolor=red,arrowinset=0]{<->}(0.5,0)(1.5,3)
\end{pspicture}
\hfill
\psset{arrowfill=false}
\begin{pspicture}(3,3)\psgrid
  \psline{->}(2,2)
  \parabola[linestyle=dotted,linecolor=red,arrowinset=0]{<->}(0.5,0)(1.5,3)
\end{pspicture}
\hfill
\begin{pspicture}(3,3)\psgrid
  \psset{arrowsize=0.2}
  \psline{->}(2,2)
  \parabola[linecolor=red,arrowinset=0]{<->}(0.5,0)(1.5,3)
\end{pspicture}

\psset{arrowscale=6}

\vspace{2cm}
\begin{pspicture}(3,3)\psgrid
  \parabola[arrowfill=true]{>>->>}(0.5,0)(1.5,3)
\end{pspicture}
\hfill
\begin{pspicture}(3,3)\psgrid
  \parabola[arrowfill=false]{>>->>}(0.5,0)(1.5,3)
\end{pspicture}

\vspace{2cm}
\begin{pspicture}(3,3)\psgrid
  \parabola[arrowfill=true]{>|->|}(0.5,0)(1.5,3)
\end{pspicture}
\hfill
\begin{pspicture}(3,3)\psgrid
  \parabola[arrowfill=false]{>|->|}(0.5,0)(1.5,3)
\end{pspicture}

\end{document}


Denis Girou
-- 
--------------------------------------------------------------------------
Institut du Développement et des Ressources en Informatique Scientifique |
Centre National de la Recherche Scientifique                             |
Bâtiment 506 - B.P. 167 - 91403 Orsay Cedex - France                     |
--------------------------------------------------------------------------

-----------------------------------------------------------------------------
The list interface (subscription, information, access to the archives) is on:
http://www.tug.org/cgi-bin/lwgate/pstricks
Otherway to unsubscribe, send mail to pstricks-request at mail.tug.org
with a blank subject and in body the line unsubscribe <email-address>
-----------------------------------------------------------------------------



More information about the PSTricks mailing list