[metapost] some question about pens
Stephan Hennig
mailing_list at arcor.de
Wed Apr 2 23:59:25 CEST 2008
Taco Hoekwater schrieb:
> Stephan Hennig wrote:
>>
>> (iv) Why are there diagonal end points in the middle and lower example
>> in the right-hand column (squared pen, squared/butt linecap)?
>
> This is already in the tracker:
>
> http://foundry.supelec.fr/tracker/?atid=129&group_id=13&func=browse
>
> Item 4, "Pensquare weirdness B".
>
> The general cause of the problem is clear to me, but fixing it is still
> a bit above my knowledge level. Basically, MP tracks the 'outside' of
> the pen, and at the reversal point of the path, it jumps 180 degrees
> (sort of) to the opposite side of the pen, across the diagonal.
I've played a little bit more with that bug. At first sight, it looks
like the jump happens at the wrong corner. Without looking at the code
(which I wouldn't understand) I had the hope that it is an off-by-one
bug in the handling of the pen shape. But the problem seems to be
buried deeper. It's not only a problem with jumping late or into the
wrong direction, MetaPost seems to do something completely different for
"odd" direction at the end points of paths.
The attached example (set paper size to A2 for viewing) draws a quarter
circle rotated by angles between 0 and 180 degrees with a step size of
10 degrees to provoke different corners of the pen being the relevant
corner (origin of the jump). The circles are drawn with linecap :=
squared in black colour and on top of that with linecap := rounded in
red colour. Assuming the result of linecap := runded is correct, I was
interested in the remaining black shape.
The results are ... well, interesting. Noteworthy, often the jump does
not even start at a corner point at all. Additionally, black shape
seems to tightly bound the red shape. But I do not really have an idea
what's going on. Maybe some kind and knowledgeable person finds the
time to look at that?
Best regards,
Stephan Hennig
beginfig(2);
path p;
p := quartercircle scaled 150;
pw := 20;
for i:=0 step 10 until 180:
linecap := squared;
draw p rotated i shifted (500*dir(i))
withpen pensquare scaled pw withcolor black;
linecap := rounded;
draw p rotated i shifted (500*dir(i))
withpen pensquare scaled pw withcolor red;
% linecap := butt;
% draw p rotated i shifted (500*dir(i))
% withpen pensquare scaled pw withcolor blue;
draw p rotated i shifted (500*dir(i))
withcolor green;
endfor
currentpicture := currentpicture shifted -llcorner currentpicture;
endfig;
end
More information about the metapost
mailing list