2

I would like to fill this triangle-like enter image description here

The code is:

\documentclass[border=0.2cm]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    % \draw [help lines] (7,0) grid (11,4);
    \draw [fill=red] (0,1.3) circle (1.3); 
    \draw [fill=blue] plot [smooth cycle,scale=0.4, xshift=18cm, yshift=1.5cm] coordinates
    {(1,0) (0,2) (1.3,4) (3.6,2) (3.6+3.6-1.3,4) (2*3.6,2) (3.6+3.6-1,0) (3.6,1)}; 
    \draw (8.55,0.98) -- ++ (0.1,-1.47) (8.7,0.99) -- (8.55+0.1,-0.49); 

\end{tikzpicture}
\end{document}

I have looked up on Filling area between two lines and an arc but I could not find a solution. I think that first I should give the name to the blue object through name path=candy. Then, I should give the command

\path[name path=twolines] (0.98) -- ++ (0.1,-1.47) (8.7,0.99) -- (8.55+0.1,-0.49);

to find the intersections. After that, with the command fill, I should be able to fill that area. The problem is that I do not know how. Maybe with the aid of \clip, but again, how?

  • 1
    If you can use one of the answers, then please mark it as accepted. – hpekristiansen Mar 7 '18 at 12:45
2

Two simple tricks can save you a tone of work. Draw that triangle and fill it as usual [fill=<color>] before drawing that moth shape, then shift the triangle upward a very small length to hide that tiny white space between the arc and the triangle side. Finally draw the curvy shape. It's a bit of an approximation but will save you much headache.

\documentclass[border=0.2cm]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    % \draw [help lines] (7,0) grid (11,4);
    \draw [fill=red] (0,1.3) circle (1.3);
    \draw [fill=red,yshift=1pt] (8.55,0.98) -- ++(0.1,-1.47) -- (8.7,0.99); 
    \draw [fill=blue] plot [smooth cycle,scale=0.4, xshift=18cm, yshift=1.5cm] coordinates
    {(1,0) (0,2) (1.3,4) (3.6,2) (3.6+3.6-1.3,4) (2*3.6,2) (3.6+3.6-1,0) (3.6,1)}; 
\end{tikzpicture}

\end{document}

enter image description here

1

You can simply draw your triangle a little too large in the top - I use the shortenoption with a negative length. -and then place your bow on top of it for a perfect result like this:

\documentclass[border=0.2cm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
   \draw [fill=red, shorten <=-0.1cm, shorten >=-0.1cm] (8.55,0.98) -- (8.65,-0.49) -- (8.7,0.99); 
   \draw [fill=blue] plot [smooth cycle,scale=0.4, xshift=18cm, yshift=1.5cm] coordinates
    {(1,0) (0,2) (1.3,4) (3.6,2) (3.6+3.6-1.3,4) (2*3.6,2) (3.6+3.6-1,0) (3.6,1)}; 
 \end{tikzpicture}
\end{document}

Filled triangle with bow

If you for some reason need a perfect filled triangle in the foreground, then you can use the inverted clip from @Jake's answer with the bow: https://tex.stackexchange.com/a/12033/8650

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.