[metapost] Trying to figure out MPLib
samjnaa at gmail.com
Sat Aug 4 14:23:06 CEST 2012
On Sat, Aug 4, 2012 at 2:16 PM, Taco Hoekwater <taco at elvenkind.com> wrote:
>> a) I am supposed to fill path_p and *fill* htap_p or *unfill* htap_p?
>> The documentation just says "fill path_p and htap_p".
> Both fills, I think (as htap is reversed already), but that should be
> obvious after a quick test.
With evenOddFill in Qt I think irrespective of the direction of the
path it will be unfilled. OK thanks.
>> b) the documentation says "the path has been pre-processed for you" --
>> by this do I understand that the outline of the stroke has been
>> converted into paths and represented as the path_p and reverse htap_p?
>> In which case, has the does this mean MPLib has a stroking algorithm?
> Yes it does, but for non-elliptical pens only.
Ouch. :-) Greedy me -- expecting too much! ;-)
But could you please mention that in the documentation?
>> Even an approximation? Is it then possible to do stroke-to-path within
>> MPLib itself?
> Yes. In fact, you get that for free whether you want to or not.
I guess this also applies only to non-elliptical pens.
BTW you mention "non-elliptical". If I define a generic bean-shape
(for example) using smooth curves and use it as a pen, would it be
stroked? Or are any pens with smooth curves a no-no and only linear
pens are stroked?
>> 3) Where is the stroke width stored?
> In the (elliptical) pen.
Um, I sorta discovered this. Will post separately.
>> 4) The mp_stroked_object documentation does not talk about complex
>> pens. Does whatever is written for mp_fill_object also apply to
Well I should have asked the question in more detail:
1) Obviously, "no pen" i.e. pen_p == NULL will never be true for a
stroked object. (Um, right?)
2) If the pen is a one-knot pen, then the client should draw path_p
with that pen.
3) If a path is drawn using a multiple-knot pen, I suppose its path
will also be pre-processed? In which case the client should not draw
but fill path_p? In which case it should become not a
mp_stroked_object but an mp_filled_object with pen_p == NULL. Right?
> If you can read a bit of lua, then mlib-pdf.lua from ConTeXt is quite
> educational. I'll send that to you by separate email.
Got it. I don't know Lua, but I know some Python (and some C and C++)
so I hope I can interpret it sufficiently. Thanks.
More information about the metapost