[metapost] Cannot fill sector

Pétiard François petiard.francois at free.fr
Sun Nov 14 18:08:55 CET 2010


  Le 14/11/2010 17:55, Yasir Malik a écrit :
>> So in my opinion MetaPost does fill the path, but the path is so
>> small that you can't see it.
>>
> Yes, when I only display "area", I see a black dot.
>
> Out of desparation, I decided to insert a control point p2 half way 
> between p0 and p1, which allowed me to create the sector; this works:

Another solution:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
beginfig(1);

u:= 1cm;

pair o, p[];
path halfcirc, area, triangle;
numeric diam,ang[];

diam:= 10u;
ang0:=10;
ang1:=72;

halfcirc:= halfcircle scaled diam;

o := (0, 0);
p0 := (diam/2, 0);
p0 := p0 rotated ang0;
p1 := p0 rotated ang1;

p0:=(o--(2*p0))intersectionpoint halfcirc;
p1:=(o--(2*p1))intersectionpoint halfcirc;
triangle:= p1--o--p0;

area:=(halfcirc cutbefore(p0) cutafter(p1))..p1..triangle..p0..cycle;

fill area withgreyscale .7;

draw halfcirc withcolor blue;
draw triangle withcolor green;

endfig;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

François



More information about the metapost mailing list