Two things:

1) How do I make the semicircle portion of my shape have the same thickness as the straight lines?

2) How do I fill the overall shape with a filling gray colour?

Here is my code so far:

\draw (10,0.4) arc (90:270:0.4cm);
\draw (10,0.4) -- (12,0.4);
\draw (10,-0.4) -- (12,-0.4);
\draw (12,0.4) arc (90:-90:0.4cm);
  • The thickness looks the same. So it might depend on the viewer. – kiss my armpit Aug 25 '14 at 19:56

It is a combination of broken path joins and viewer rendering quality. You can draw it at one shot or put a node instead.

\draw[blue,fill=blue!30] (0,0.4) arc (90:270:0.4cm)-- (2,-0.4) arc (-90:90:0.4cm)--cycle;
\node[draw=red,fill=red!30,rounded corners=0.4cm,minimum height=0.8cm,minimum width=2.8cm,inner sep=0mm,transform shape] at (1,1) {};

enter image description here


A solution with PSTricks just for fun.


enter image description here


Just for comparison, in Metapost you can either draw the path directly using halfcircles or use the rboxes library to make rounded boxes.

enter image description here


% A macro that returns the path of a rectangle with rounded ends
vardef vessel(expr width, height) = 
   halfcircle rotated -90 scaled height shifted (+1/2 width,0) --
   halfcircle rotated +90 scaled height shifted (-1/2 width,0) --

% for the alternative approach
input rboxes;


   % draw the shape centred at the origin
   draw vessel(40,20);

   % in order to fill, draw and label the shapes, you can save them as path variables
   path a,b; 

   a = vessel(55,21) shifted 30 up;
   fill a withcolor .4 blue + .6 white;
   draw a withcolor .8 blue;
   label(btex Vessel $V_1$ etex, center a);

   b = vessel(55,21) shifted 55 up;
   fill b withcolor .4 red + .6 white;
   draw b withcolor .8 red;
   label(btex Vessel $V_2$ etex, center b);

   % or you might prefer the "rboxes" approach
   rboxit.c(btex Vessel $V_3$ etex);
   c.dx = 18; c.dy = 5;
   c.s = 70 up; 
   fill bpath.c withcolor .85 white;


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.