Semitransparent graphics?

Denis Girou Denis.Girou at idris.fr
Wed Aug 5 20:37:12 CEST 1998


-----------------------------------------------------------------------------
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.


>>>>> "Nigel.Stanger" == nigel.stanger at stonebow.otago.ac.nz (Nigel Stanger) writes:

    Nigel.Stanger > I have a bit of an interesting problem with a diagram I'm working on. It's
    Nigel.Stanger > effectively a graph (in the mathematical sense) consisting of a collection
    Nigel.Stanger > of ovalnodes (I'm using pstricks btw), some nested within others, with
    Nigel.Stanger > arcs connecting the nodes. Some of the connectors connect to nested nodes,
    Nigel.Stanger > which means I have to do a \ncarc[border=2pt] to make a nice little gap.
    Nigel.Stanger > This is all fine.
    Nigel.Stanger > 
    Nigel.Stanger > The problem I've got is that I want to highlight a subset of the graph by
    Nigel.Stanger > surrounding the appropriate nodes with a filled gray blob shape. I can
    Nigel.Stanger > produce the blob shape fine, but (a) I have to draw the blob first so it
    Nigel.Stanger > doesn't wipe out the stuff it's highlighting, and (b) the [border=2pt]
    Nigel.Stanger > options on the \ncarc commands means that they leave a big white streak
    Nigel.Stanger > through the middle of the blob, which looks bad. Setting the bordercolor
    Nigel.Stanger > is no use, beacuse some of the connectors pass outside the blob area, so
    Nigel.Stanger > I'd get gray streaks instead of white ones, which would look even worse.
    Nigel.Stanger > (If you can't visualise what I'm trying to do here, I can sent you an
    Nigel.Stanger > example.)
    Nigel.Stanger > 
    Nigel.Stanger > So, what I'm wondering is if it's possible to draw the blob over the top
    Nigel.Stanger > of the graph in a semitransparent manner; effectively some sort of
    Nigel.Stanger > additive drawing mode or something similar. At the moment the blob is an
    Nigel.Stanger > EPS, but that's only because I constructed it using a drawing tool ---
    Nigel.Stanger > building it manually in pstricks/whatever is OK if I have to.
    Nigel.Stanger > 
    Nigel.Stanger > I couldn't find anything obvious in pstricks and I don't really have the
    Nigel.Stanger > time to go on a massive search for something to do this --- I've got a
    Nigel.Stanger > deadline approaching, so if I can't find anything soon, I'll just `unfill'
    Nigel.Stanger > the blob and use just the frame, which will work but not look quite as
    Nigel.Stanger > good.

  I did not (yet) receive the example but I believe to understand the
question. The desired effect can be obtained by usage of the clipping
mechanism of PSTricks.

  I think it is not too difficult to understand and to adapt but it can be
considered as rather "advanced" usage. For description of the clipping
mechanism see pages 54-55 of the documentation. Another problem to solve is
that the highlighted area must be drawn exactly at the same place, but the
psmatrix entries change the horizontal and vertical positions. I solve here
this problem using a node defined at the beginning of the psmatrix environment.

  It also require that the highlighted area is drawn with PSTricks, but I do
not see why you could not been able to do that.

\documentclass{article}

\usepackage{pstcol} % To use the standard "color" package with PSTricks
\usepackage{pst-node}

\definecolor{LightGray}{gray}{.93}

% The area to highlight
\newcommand{\HighlightedArea}[1][linestyle=solid]{%
\psccurve[#1](-1.5,-5)(3,-2.5)(10,-11)(3,-9)}

\pagestyle{empty}

\begin{document}

\begin{center}
  \Huge
  \SpecialCoor
  \begin{psmatrix}[rowsep=4,colsep=4,mnode=oval,
                   fillstyle=solid,fillcolor=white]
    \pnode{Origin} % To be able to redraw later the highlighted area
                   % at the same place
    % The area to highlight (starting point at (0,0))
    \rput(Origin){%
      \pscustom[linewidth=2pt,fillstyle=solid,fillcolor=LightGray]{%
        \HighlightedArea}}
    One   & Two \\
    Three & [colsep=6] Four \\
    Five  & Six
  \end{psmatrix}
  % Connections
  \psset{fillstyle=none,arrows=->,arrowscale=2,border=2mm,nodesep=3pt}
  \ncarc{1,1}{2,2}
  \ncarc{1,1}{3,2}
  \ncarc{3,1}{1,2}
  \ncarc[arcangle=-60]{3,2}{1,2}
  % We redraw the highlighted area as clipping region
  \begin{psclip}{\rput(Origin){\HighlightedArea[linewidth=2pt,border=0]}}
    % We redraw the line connections, but only the parts inside
    % the highlighted area, with a bordercolor equal to the background one
%    \psset{bordercolor=red} % To clearly see the effect...
    \psset{bordercolor=LightGray}
    \ncarc{1,1}{3,2}
    \ncarc{3,1}{1,2}
    \ncarc[arcangle=-60]{3,2}{1,2}
    % We redraw the highlighted area one time more, here to have everywhere
    % for it the correct width of the line...
    \rput(Origin){\HighlightedArea[linewidth=2pt,border=0]}
 \end{psclip}
\end{center}

\end{document}

Denis Girou
--
---------------------------------------------------------------------------
Institut du De'veloppement et des Ressources en Informatique Scientifique |
Centre National de la Recherche Scientifique                              |
Ba^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