Suppose I have build a cycle path with bulidcycle:
path pa[];
pa.0:=(-6u,0){dir 90} .. (0,8u){dir 0};
pa.01:=pa.0 reflectedabout(origin, (0,1));
pa.1:=(-6u,0){dir -90} .. (0,-3u){dir 0};
pa.11:=pa.1 reflectedabout(origin, (0,1));
pa.2:=(3u,-6u)--(3u,12u);
pa.3:=buildcycle(pa.01,pa.11,pa.2);
draw pa.3 withcolor red;
Then it is quite easy to fill it with color,
fill pa.3 withcolor red;
My problem is how to fill it with slanted lines?
Can we define a function, named as draw_fill(expr dr, pa), which will fill the path pa with lines in the direction dr?
EDIT
After a while, I figure out that we can do it by clip as: first to define a function called draw_clip,
def draw_clip(expr pat, len, gap) =
begingroup
u:=10pt;
for i=-len upto len:
draw (-len*u*dir(40)--len*u*dir(40)) shifted (0,i*u*gap);
endfor;
clip currentpicture to pat;
endgroup;
enddef;
Then before any draw, do the clip:
draw_clip(pa.3,20,.5,40);
%continu your other draws
maybe this is a not so perfect solution (as you must clip it first before anyother draw). So my question can be changed into what is the best way to do it?
Another small question will be that if you want to mark the region by a label, then the label need to be changed into something like
%fix the label
picture lab;
lab=thelabel.rt(btex $\Omega$ etex, (4u, 2u));
unfill bbox lab;
draw lab





hatchingpackage could be useful for this: http://www.ctan.org/pkg/hatching – Franck Pastor Jan 21 '14 at 15:40