[metapost] Prevent a pen from leaking

Philipp von Weitershausen philipp at weitershausen.de
Mon Apr 27 21:19:11 CEST 2009


Hi there,

before I begin I should point out that I'm a MetaPost novice. I've tried 
to find an answer for my problem in the numerous excellent tutorials out 
  there but have failed so far.

I'm trying to extend the excellent FeynMF package to allow vertex 
decorations to be drawn with an optional user-specified width.  For this 
I've extended the following macro (my addition is the 'if' after the 
comment)::

   vardef vdraw_vertex suffix v =
     if known v.decor.shape:
       % NEW: user-specified width
       if known v.decor.wd:
         save currentpen;
         pen currentpen;
         pickup pencircle scaled v.decor.wd;
       fi

     ... % drawing of the actual vertex shape happens here

   enddef;

The problem I now have is that the scaled pen *sometimes* leaks to 
outside this macro, thereby affecting the line width of other objects 
that are drawn. Helpful people have already pointed me to "draw ... 
withpen ...". This is not very useful here, however, because the 
vdraw_vertex macro above doesn't actually do the drawing itself, it 
calls upon other macros to do that.

To fully reproduce the problem, one may obtain my modifications to 
FeynMF from my git repository:

   git clone http://iktp.tu-dresden.de/~philipp/feynmf.git

Here's an example document that reproduces the problem I see in my 
documents:

   http://iktp.tu-dresden.de/~philipp/penleak.tex

Any pointers would be much appreciated.

Thanks,
Philipp



More information about the metapost mailing list