5

I didn't expected the following intersection in my graph (here, for sake of minimalism, only locally exposed). Now, I need to know, how to colour the two sides of the ribbon I (locally) drew as follows:

enter image description here

How to constrain the filling to the curves in the wished area?

\documentclass{standalone}

\usepackage{tikz}


\begin{document}
 \begin{tikzpicture}

\fill[double,blue, opacity=.39,
double distance=1.0 pt,thick,smooth] plot[smooth ] coordinates{
    (12.68,-.96)  (12.68-.085,-.96-.063) (12.68+.25, -.96+0.001)  (12.68+.282, -.96+.1)  
    (12.68,-.96) } ;

\draw[ opacity=.4]
(12.68,-.96) ..controls +( .4,.083) and +( .1,-.0811 ) ..  (12.88,-.75)  ;

\draw[ opacity=.4]
(12.61,-1.01) ..controls +( .46,.05) and +( .135,-.0811 ) ..  (12.839,-.81)  ;

 % second, non-smooth attempt
\begin{scope}[xshift=.5cm] 
 \fill[double, red!60!black, opacity=.39,
  double distance=1.0 pt]
    (12.68,-.96) --  +(-.085, -.063) -- +(.255, 0.001)  -- +(.289, .1) --  (12.68,-.96)  ; 


\draw[ opacity=.4]
(12.68,-.96) ..controls +( .4,.083) and +( .1,-.0811 ) ..  (12.88,-.75)  ;

\draw[ opacity=.4]
(12.61,-1.01) ..controls +( .46,.05) and +( .135,-.0811 ) ..  (12.839,-.81)  ;   
 \end{scope}


\end{tikzpicture}
\end{document}
c.p.
  • 4,636

2 Answers2

3

This is not a complete answer, but will hopefully get you going in the right direction. If I understand it correctly, this question is a difficult one, since you are essentially trying to find the "maximum" point of a bent curve so that you can fill up the space to that point. The naive solution is to use \fill with the same path coordinates you have, reversing one of the paths:

\begin{tikzpicture}

\draw[ opacity=.4]
(12.68,-.96) ..controls +( .4,.083) and +( .1,-.0811 ) ..  (12.88,-.75)  ;

\draw[ opacity=.4]
(12.61,-1.01) ..controls +( .46,.05) and +( .135,-.0811 ) ..  (12.839,-.81)  ;

\fill[ opacity=.4,color=blue]
(12.61,-1.01) ..controls +( .46,.05) and +( .135,-.0811 ) ..  (12.839,-.81)  
--
(12.88,-.75) .. controls +( .1,-.0811 ) and +( .4,.083) .. (12.68,-.96);

\end{tikzpicture}

You see that part of the "ribbon" is filled, but not around the area where the two curves "turn back" and change direction:

enter image description here

My initial thought is to use tikz-3dplot because the ribbon you're trying to replicate somehow exists in 3 dimensions, and so with that package you can find a suitable projection of it - but actually drawing it in 3 dimensions also seems very difficult.

1

Based on the solution given by jlv,

enter image description here

 \begin{scope}
        \clip (12.61,-1.01) rectangle (12.97,-.888)  ;
    \fill[ opacity=.4,color=blue]
    (12.61,-1.01) ..controls +( .46,.05) and +( .135,-.0811 ) ..  (12.839,-.81)  
    --
    (12.88,-.75) .. controls +( .1,-.0811 ) and +( .4,.083) .. (12.68,-.96);
    \end{scope} 


\begin{scope}
    \clip  (12.57,-.877) rectangle (13,-.477)  ;
\fill[ opacity=.4,color=red]
(12.61,-1.01) ..controls +( .46,.05) and +( .135,-.0811 ) ..  (12.839,-.81)  
--
(12.88,-.75) .. controls +( .1,-.0811 ) and +( .4,.083) .. (12.68,-.96);
\end{scope} 
c.p.
  • 4,636