[metapost] fill bpath does not work
piotr.zielinski at gmail.com
Mon Oct 9 23:09:58 CEST 2006
On 09/10/06, j.romildo at gmail.com <j.romildo at gmail.com> wrote:
> > % test.mp
> > prologues := 2;
> > input boxes;
> > beginfig(6)
> > boxjoin( a.e = b.w - (4mm,0) );
> > boxit.a1("1");
> > boxit.a2("2");
> > boxit.a3("3");
> > fill bpath a1 withcolor 0.8white;
> > fill bpath a2 withcolor white;
> This line should be commented out.
> > fill bpath a3 withcolor 0.8white;
> > drawboxed(a1,a2,a3);
> > endfig;
> > end
> > And the output image can be seen at
> > http://www.decom.ufop.br/prof/romildo/misc/test.6, while the the figure
> > I was expecting should look like this
> > http://www.decom.ufop.br/prof/romildo/misc/test.new.6
> > Can anybody take a quick look at this and tell me why that happens?
Add the line:
after the line 'boxit.a3("3");'
Brief rationale: after creating boxes with "boxit", metapost only
knows the relative positions of your boxes, that is, a1 relative to
a2, and a2 relative to a3. Also, metapost does not know their sizes.
Every instruction drawing a box uses fixsize and fixpos to compute the
size and the absolute position of a box. So your original program
worked fine, because sizes of all boxes were computed. However, if
you do not draw bpath a2, then the size of a2 is unknown, so when
bpath a3 tries to compute its absolute position, it can put it in the
same place as a1 because it is not constrained by the size of a2
(which can be set to any number, in particular, a negative one).
In short: if you draw your boxes one by one, then fix their sizes and
positions before hand.
Piotr Zielinski, Research Associate
Cavendish Laboratory, University of Cambridge, UK
More information about the metapost