[metapost] wrong bounding box with pencircle
Boguslaw Jackowski
B_Jackowski at GUST.org.pl
Sat Jun 22 19:30:44 CEST 2013
Hello,
SH:
> in the attached example bounding boxes are not as expected for a squared
> and a butt linecap. (The line is drawn with a pencircle.) Is this a
> known issue?
I believe that it is a long-standing issue. For the first time, as far
as I remember, it was raised by Antonin Strejc <STREJC at vc.cvut.cz>
(email from 22 Jul 1998 to: metafont at ens.fr; subject
"MetaPost draw & bounding box"). Antonin's example was
beginfig(100);
linecap:=butt;
pickup pencircle scaled 10;
draw(50,0)--(50,100);
endfig;
end;
Then, the problem several times "payed a visit" to the MF/MP discussion
list. In particular, the problem was disscussed in the thread
"some question about pens", triggered by Stephan Hennig 01 Apr 2008. :-)
In this thread, Hartmut Henkel <hartmut_henkel at gmx.de> pointed out that
metapost doesn't calculate the bounding box right in this case, see:
prologues := 3;
beginfig(1);
path hc;
hc := halfcircle scaled 200;
linecap := squared;
draw hc shifted (150,300) withpen pencircle scaled 50;
draw bbox(currentpicture) withcolor red;
currentpicture := currentpicture shifted -llcorner(currentpicture);
endfig;
end
if you comment out the linecap line, you get a tight bounding box.
and Dan Luecking <luecking at uark.edu> provided an example showing that
miter-limitted paths can get wrong bounding boxes:
beginfig(100)
miterlimit := 11;
linejoin := mitered;
draw (0,0)--(72,7)--(0,14) withpen pencircle scaled 2bp;
endfig;
end.
(the right vertex protrudes beyond the bounding box).
I got accustomed so much to this "feature" of MP that
I did not not emphasize it in my example which I sent
a few days ago:
% file err-pen2.mp
linecap:=butt;
beginfig(100) draw (0,0)--(5cm,0) withpen pensquare scaled 3mm; endfig; % WRONG (oblique ends)
beginfig(101) draw (0,0)--(5cm,0) withpen pencircle scaled 3mm; endfig; % OK
end.
% EOF
In the beginfig(101) line of the code, the resulting bounding box
is NOT OK which I took for granted. :-)
All in all, there is much to be done with MP strokes. On the theoretical
part too. (Maybe here also using bitmaps as an auxiliary mean could
be a help?)
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