[metapost] Trying to figure out MPLib

Taco Hoekwater taco at elvenkind.com
Sat Aug 4 10:46:55 CEST 2012

On 08/04/2012 06:46 AM, Shriramana Sharma wrote:
> Based on this my questions regarding mp_fill_object and mp_stroked_object:
> 1) Do I understand correctly that:
> a) If this object is produced by fill, then there is no pen.


> b) If this object is produced by filldraw, then there is a pen.


> c) It is not possible for an object to be filled with one colour and
> drawn with another -- for that I have to fill and draw the same path
> separately using different colours? (This is obviously not an mplib
> question but a generic metapost one.)


> 2) In the case of a complex pen:
> 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.

> 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.

> 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.

> c) If only filling (and unfilling if htap_p!=NULL) needs to be done,
> pen_p can just be ignored, right?


> 3) Where is the stroke width stored?

In the (elliptical) pen.

> 4) The mp_stroked_object documentation does not talk about complex
> pens. Does whatever is written for mp_fill_object also apply to
> mp_stroked_object?


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.

Best wishes,

More information about the metapost mailing list