3

I am new in metapost and I am unsure as to re-define the withcolor command to revert back to the metapost default.

I am trying to draw the cross section of a cylinder, where the inner circle is empty, but the outer marked with straight lines.

Can you please help me? I am very tight with time!

This is the code so far:

input hatching;

u := 1cm;
path circle; 
circle = fullcircle scaled 10u;
outputtemplate:="%j%c.mps";
beginfig(1); 
hatchfill circle withcolor (45, 5mm, -.5bp);
draw circle;
draw fullcircle scaled 5u; % This needs to be filled with color white
endfig;
end 

This is what it looks like:

enter image description here

5

Save the inner circle as a path first, unfill it and then draw it.

input hatching;

u := 1cm;
path circle; 
circle = fullcircle scaled 10u;
outputtemplate:="%j%c.mps";
beginfig(1); 
hatchfill circle withcolor (45, 5mm, -.5bp);
draw circle;
path inner_circle;
inner_circle := fullcircle scaled 5u; % This needs to be filled with color white
unfill inner_circle;
draw inner_circle;
endfig;
end 

enter image description here

  • Thank you daleif for your fast. I was unaware of the unfill command! You made my afternoon. – user2822693 Feb 20 '14 at 15:23
  • At the other end, I did not know about hatching – daleif Feb 20 '14 at 15:27
  • 1
    Haha. Give and receive! – user2822693 Feb 20 '14 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.