[metapost] Prevent a pen from leaking

Philipp von Weitershausen philipp at weitershausen.de
Tue Apr 28 14:21:11 CEST 2009


Philipp von Weitershausen wrote:
> 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.

The problem has been tracked down now, it wasn't at all due to the pen 
"leaking" but due to the v.decor.wd property leaking to other vertices.

You may ignore this thread now :)

Philipp



More information about the metapost mailing list