5

I am trying to fill the area between the lines and arc in latex. Below is the code I have used and it's not filling up the whole area. I am sure there is somewhere I am not getting it right, I am new to this platform. Can someone help? Here are my code and the output Filled area after running the code

\begin{tikzpicture}
\draw[name path=A](0.4,0)--(0.2,0)--(0.2,-0.3)--(0.8,-0.5)  (-0.8,-0.5)-- (-0.2,-0.3)--(-0.2,0)--(-0.4,0);
\draw[name path=B](0.8,-0.5)--(0.3,-2)(-0.3,-2)--(-0.8,-0.5)-- (0.8,-0.5);
\draw[name path=C](0.6,-2)++(180:0.3) arc (0:-180:0.3);
%\draw[name path=D](-0.8,-0.5)--(0.8,-0.5);
\begin{pgfonlayer}{bg}
\fill [orange!90,
intersection segments={
    of=A and B,
    sequence={L2--R2}
}];
\fill [orange!90,
intersection segments={
    of=B and C,
    sequence={L2--R2}
}];
\end{pgfonlayer}
\end{tikzpicture}
  • Welcome to TeX.SX! Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass and ending with \end{document}. – Bobyandbob Jun 4 '17 at 15:35
7

If the desired result is

enter image description here

you can use:

\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw
  (0.4,0)--(0.2,0)--(0.2,-0.3)--(0.8,-0.5)
  (-0.8,-0.5)-- (-0.2,-0.3)--(-0.2,0)--(-0.4,0)
;
\draw[fill=orange!90]
  (0.8,-0.5)--(0.3,-2)
  arc (0:-180:0.3)
  --(-0.8,-0.5)--cycle
;
\end{tikzpicture}
\end{document}
5

A Metapost alternative, with a bit of fiddling to make the curve at the bottom look neat by finding the tangent points. You can (I believe) do something similar in tikz using the tangent coordinate system. a diagram with a vessel, almost full of orange fluid

\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
    % set the various points
    z4 = 190 up rotated 25;
    z3 = 200 up rotated 5;
    z2 = z3 shifted 30 up;
    z1 = z2 shifted 20 left;

    % now find the tangent point
    path c, c'; 
    c = fullcircle scaled 50 rotated 90;
    c' = fullcircle scaled abs(z4) shifted 0.5 z4;
    (t,t') = c intersectiontimes c';
    path side, vessel;
    side = z1--z2--z3--z4--subpath(t,4) of c;
    vessel = side & reverse side reflectedabout(up,down);

    level = 3.1;
    fill subpath(0+level,length(vessel)-level) of vessel 
         -- cycle withcolor 1/2[red + 1/2 green, 15/16 white];
    draw vessel withpen pencircle scaled 1;

endfig;
\end{mplibcode}
\end{document}

Compile with lualatex (or strip off the LaTeX wrappers and use mpost)

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.