[pstricks] line macro

Patrick Drechsler patrick at pdrechsler.de
Tue Nov 13 20:03:05 CET 2007


when placing arrows on top of grayscaled images solid colored lines
are sometimes hard to see (especially if one wants to refrain from
using colors).

Maybe this macro is useful of others (example usage in main document):

--8<---------------cut here---------------start------------->8---
%% Macro "PstShadowline"
%% Usage: \PstShadowline[<parameter>](x1,y1)(x2,y2)
%% Use the same way as psline. It will draw a "framed" outline around the
%% line. The width and color of the outline can be altered by
%%    outercolor
%%    and outersize (in pt).
%% The color of the inner line can be altered with
%%    innercolor
\define at key[psset]{}{innercolor}{\pst at getcolor{#1}\Pst at innercolor}%
\define at key[psset]{}{outercolor}{\pst at getcolor{#1}\Pst at outercolor}%
\define at key[psset]{}{outersize}{\def\psk at outersize{#1}}
\psset[]{outercolor=black, innercolor=white, outersize=1.6pt}
\def\PstShadowline{\pst at object{PstShadowline}}%
\def\PstShadowline at i(#1)(#2){{%
    \pst at killglue%
    \addbefore at par{linewidth=1pt,unit=1cm}%
    \use at par%
    %% Recalculate end coordinate:
    \pst at getcoor{#1}\pst at tempa%
    \pst at getcoor{#2}\pst at tempb%
    \pst at tempa /Y1 exch \pst at number\psyunit div def
    /X1 exch \pst at number\psxunit div def
    \pst at tempb /Y2 exch \pst at number\psyunit div def
    /X2 exch \pst at number\psxunit div def
    /XC X2 X1 sub def
    /YC Y2 Y1 sub def
    XC X1 add
    YC Y1 add){End}%
    \psset{unit=1cm,shadow=true,linecolor=\Pst at innercolor,shadowcolor=\Pst at outercolor, shadowsize=\psk at outersize}
  \psset{linewidth=1.2pt, arrows=|<->|,arrowinset=0,arrowscale=1.5}
  %% new macro:
--8<---------------cut here---------------end--------------->8---


"Physics is like sex. Sure, it may give some practical results, but
that's not why we do it." (Richard Feynman)

More information about the PSTricks mailing list