[metapost] How to use a thinner pen?

Boguslaw Jackowski B_Jackowski at GUST.org.pl
Wed Jun 18 10:22:40 CEST 2008


Hi,

Rodolfo Medina:
> It seems that I don't manage to use a pen thinner than the default 0.5bp.
[...]
> beginfig(1);
> numeric u;
> u = 1cm;
> draw (0,-u)--(0,0)--(0,4u);
> pickup pencircle scaled 2pt;
> draw (-2u,0)--(0,0)--(4u,0);
> pickup pencircle scaled 0.0000000000000001pt;
> draw (0,u)--(u,u);
> endfig;
> 
> end

Taco Hoekwater:
> I suspect that your dvips printer (www) has a resolution that
> is so low that every line width below 1pt becomes one pixel.

My tuppence worth.

Note that for MP 0.0000000000000001pt; = 0pt; indeed, in the resulting
file you have the following relevant statement

  0 0 dtransform truncate idtransform setlinewidth pop

which "picks up" a PostScript pen of width 0.

According to the PostScript Language specification, lines having thickness
explicitly 0 are displayed as 1-pixel ones:

     A line width of 0 is acceptable, and is interpreted as the
     thinnest line that can be rendered at device resolution --
     1 device pixel wide. However, some devices cannot reproduce 1-pixel
     lines, and on high-resolution devices, they are nearly invisible.
     Since the results of rendering such "zero-width" lines are
     device-dependent, their use is not recommended.

     The actual line width achieved by stroke can differ from the
     requested width by as much as 2 device pixels, depending on the
     positions of lines with respect to the pixel grid. Automatic
     stroke adjustment (see setstrokeadjust) can be used to ensure
     uniform line width.

In MP, the thickness of a stroked line is not given explicitly, but
computed using the dtransform and idtransform operations (i.e., "delta
transform" and "inverse delta transform", whatever their meaning) -- see
above; moreover, the intermediate result is being truncated.

Thus, if for a given transformation the result comes out zero, the 
relevant line will be displayed as a 1-pixel one; the advantage is that 
very thin lines never disappear, disadvantage -- that their optical 
thickness can be misleading at low resolutions.

Cheers -- Jacko

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  Bogus\l{}aw Jackowski: B_Jackowski at GUST.ORG.PL
----------------------------------------------------------------
  Hofstadter's Law: It always takes longer than you expect, even
                    when you take into account Hofstadter's Law.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-




More information about the metapost mailing list