[pstricks] positioning hatches

Herbert Voss Herbert.Voss at alumni.TU-Berlin.DE
Thu Apr 22 17:52:25 CEST 2004


vin.gui wrote:
> Herbert Voss wrote:
> 
>> vin.gui wrote:
>>
>>> Is there a way to adjust the position of hatches ?
>>> For instance, I draw a triangle, and I would like the hatches to
>>> go through a particular vertex of this triangle...
>>
>>
>>
>> hope, it helps
>>
> 
> Yes thanks !
> BTW, is there a way to know at which point the hatches will start ?
> After a few tests, it does not seem to depend on the point at which the 
> triangle starts:

there are only horizontal and vertical lines
and they are rotated by \psk at hatchangle

I don't know why the values are rounded, but here
is a version, which has exactly lines parallel to
the hypotenuse

Herbert


\documentclass{article}
\usepackage{pstricks}
\makeatletter
\def\setHatchAngle(#1,#2){%
     \edef\pst at HatchAngle{#1\space #2\space atan 90 sub rotate }}
\def\pst at linefill{%
     \pst at HatchAngle
     \psk at hatchwidth SLW
     \pst at usecolor\pshatchcolor
     \psk at hatchsep \tx at LineFill%
}
\pst at def{LineFill}<
gsave abs CLW add /a ED a 0 dtransform %%%%%% no round (hv 2004-04-22)
%gsave abs CLW add /a ED a 0 dtransform round exch round exch
2 copy idtransform exch Atan rotate idtransform pop /a ED .25 .25
itransform pathbbox /y2 ED a Div ceiling cvi /x2 ED /y1 ED a
Div cvi /x1 ED /y2 y2 y1 sub def clip newpath 2 setlinecap systemdict
/setstrokeadjust known { true setstrokeadjust } if x2 x1 sub 1 add { x1
a mul y1 moveto 0 y2 rlineto stroke /x1 x1 1 add def } repeat grestore
pop pop >
\makeatother

\pagestyle{empty}
\begin{document}
\def\truc{
     \begin{pspicture}(10,8)
     \setHatchAngle(8,10)
     \pspolygon[fillstyle=crosshatch](0,0)(10,8)(10,0)
     \psdots[linecolor=red](0,0)
\end{pspicture}
}
\psset{hatchsep=2mm}
\truc

\psset{hatchsep=3mm}
\truc

\psset{hatchsep=5.5mm}
\truc

\end{document}



-- 
http://TeXnik.de/
http://PSTricks.de/
http://perce.de/LaTeX/math/Mathmode-TeX.pdf
http://www.dante.de/faq/de-tex-faq/
http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes




More information about the PSTricks mailing list