[pstricks] line macro
Patrick Drechsler
patrick at pdrechsler.de
Tue Nov 13 20:03:05 CET 2007
Hi,
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---
\documentclass{article}
\usepackage{pstricks,pstricks-add}
\usepackage{multido}
\SpecialCoor
\makeatletter
%% 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%
\pnode(!%%
\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}
\multido{\iy=0+10}{36}{%
\rput(#1){\psline[shadowangle=\iy](0,0)(End)}%
}%
}\ignorespaces}%
\makeatother
%%
\begin{document}
\begin{pspicture}[showgrid=true](5,5)
\psframe[fillstyle=hlines,hatchwidth=3pt](1,1)(5,4)
\psset{linewidth=1.2pt, arrows=|<->|,arrowinset=0,arrowscale=1.5}
%%
\psline(1.5,0)(1.5,3)
\psline[linecolor=white](2,0)(2,3)
\psline[doubleline=true,arrowscale=0.6](2.5,0)(2.5,3)
%% new macro:
\PstShadowline(3.5,0)(3.5,3)
\PstShadowline[outercolor=red,outersize=4pt](4.5,0)(4.5,3)
\end{pspicture}
\end{document}
--8<---------------cut here---------------end--------------->8---
Cheers,
Patrick
--
"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