# Bad line overlap in PSTricks figure

Consider the following code (which is almost the same as this):

\documentclass{article}

\usepackage{animate}
\usepackage[locale=DE]{siunitx}

\def\vinkelA{12 }
\pstFPdiv\faktor{1}{3}
\makeatletter
\pst@getsinandcos{\vinkelA}
\pstFPmul\MaxLW{2}{\MaxLW}
\def\PolyLine{%
\psline(B)(A)(D)
}

\def\light#1{% Sun beams.
\psset{
unit=0.7
}
\begin{pspicture}(-\faktorC,-\faktorC)(\faktorC,\faktorD)
\pst@getsinandcos{#1}
\ifnum #1 = 90 \let\RelLW\MaxLW
\else
\ifnum #1 > 90 \pstFPmul\RelLW{\MaxLW}{\pst@cos}
\else          \pstFPmul\RelLW{\MaxLW}{\pst@sin}
\fi
\fi
\pnode(0,0){C}
% Filling
\pscustom[
linewidth=2pt,
linecolor=red,
]{\PolyLine}
\begin{psclip}{% Clipping.
\pscustom[
linestyle=none,
dimen=inner
]{%
\PolyLine
}
}
\pcline[
linecolor=yellow,
linewidth=\RelLW,
](0,0)(!#1 dup 90 ne {-1 exch neg Tan neg} {0 -1} ifelse)}
\end{psclip}
\pscustom[
linewidth=2pt,
linecolor=red
]{\PolyLine}% Better clipping.
\psline[
linestyle=dotted
\pswedge(0,0){1}{!180 #1 sub}{180}
\uput{1}[!180 #1 2 div sub](0,0){\footnotesize \SI{#1}{\degree}}
\psline[
linestyle=dotted
](0,0)(!3 180 #1 sub PtoC)
}
\end{pspicture}
}

\begin{document}

\begin{animateinline}[poster=first,controls,palindrome]{2}
\multiframe{121}{iA=30+1}{\light{\iA}}
\end{animateinline}

\end{document}


I don't like the way red curve 'hits' the yellow area; how do I improve this? (I'm not exactly sure what I want but I'll tell if the answer(s) given is/are what I'm looking for.)

P.S. Feel free to add more tags.

-
you could draw the red lines first, and then the yellow thing on top? too simplistic? :) –  cmhughes Sep 21 '13 at 15:30
@cmhughes It could be good! :) My problem is that I put the code for the red curve in the wrong place; the upper part of the yellow parallellogram disappears when I rearrange the code. Can I get you to rearrange the code correctly for me in an answer? –  Svend Tveskæg Sep 21 '13 at 15:41

\documentclass{article}

\usepackage{animate}
\usepackage[locale=DE]{siunitx}

\def\vinkelA{12 }
\pstFPdiv\faktor{1}{3}
\makeatletter
\pst@getsinandcos{\vinkelA}
\pstFPmul\MaxLW{2}{\MaxLW}
\newcommand\PolyLine[1][\vinkelA]{%
\psline(B)(A)(D)

\def\light#1{% Sun beams.
\psset{unit=0.7}
\begin{pspicture}(-\faktorC,-\faktorC)(\faktorC,\faktorD)
\pst@getsinandcos{#1}
\ifnum #1 = 90 \let\RelLW\MaxLW
\else
\ifnum #1 > 90 \pstFPmul\RelLW{\MaxLW}{\pst@cos}
\else          \pstFPmul\RelLW{\MaxLW}{\pst@sin}
\fi
\fi
% Filling
\pscustom[
linestyle=none,
\pscustom[linewidth=2pt,linecolor=red]{\PolyLine[0]}
\begin{psclip}{% Clipping.
\pscustom[linestyle=none,dimen=inner]{%
\PolyLine}
}
}
](0,0)(!#1 dup 90 ne {-1 exch neg Tan neg} {0 -1} ifelse)}
\end{psclip}
\pswedge(0,0){1}{!180 #1 sub}{180}
\uput{1}[!180 #1 2 div sub](0,0){\footnotesize \SI{#1}{\degree}}
\psline[linestyle=dotted](0,0)(!3 180 #1 sub PtoC)
}
\end{pspicture}
}

\begin{document}

\begin{animateinline}[poster=first,controls,palindrome]{2}
\multiframe{121}{iA=30+1}{\light{\iA}}
\end{animateinline}

\end{document}


-
It looks good. Come to think of it, I would like the red curve to be cut off vertical at both sides of the yellow parallellogram since the drawing illustrates light coming through a hole in a ceiling. Furthermore, the light should go through the hole hitting the top of the left-hand side of the curve and the bottom of the right-hand side of the curve. (I hope it makes sence.) –  Svend Tveskæg Sep 21 '13 at 16:11
I changed the code. Substract the linewidth from the clip area for the yellow line. A vertical cut of the line is possible if you shorten the line at the end yellow edges. –  Herbert Sep 21 '13 at 16:24
I see that you have incorporated the subtraction of the linewidth (nice!) but it is not compeltely perfect; the right-most part of the parallellogram overlaps a tiny bit of the red curve. Also, I can't figure out how to get a vertical cut of the line. –  Svend Tveskæg Sep 24 '13 at 5:24