I would like to draw figures like these, where some part is colored between 2 paths, which are defined independantly.
So in code the question is the following.
Given curves :
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (1.5, 5) .. controls (1.5,4) and (1, 3.5) .. (0,3.5) .. controls (-1,3.5) and (-1.5,3) .. (-1.5,2) .. controls (-1.5541,1.2387) and (-1.4786,0.9369) .. (-1.5,0) ;
\draw (-1,0) .. controls (-1,1) and (-1,2.5) .. (-0.5,2.5) .. controls (0,2.5) and (0,1.5) .. (0.5,1.5) .. controls (1,1.5) and (0.5,3) .. (1.5,3);
\end{tikzpicture}
\end{document}
How to fill the region to the right of the left curve and to the right of the left curve with the color red ?
--
Previous code
So far, I can describe manually the region by adding points and explicitely filling them. But It would be nicer to draw just the boundaries of such regions and ask to color them in one go.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, intersections}
\begin{document}
\begin{tikzpicture}[scale=1, transform shape]
\coordinate (v1) at (0,3) {};
\coordinate(v2) at (0,0) {};
\coordinate (v3) at (-3,3) {};
\coordinate (v4) at (-3,0) {};
\coordinate (v5) at (3,3) {};
\coordinate (v6) at (3,0) {};
\fill[fill=blue!20]
(v4.center) -- (v3.center) -- (v1.center) -- (v2.center) -- cycle;
\fill[fill=yellow!10]
(v1.center) -- (v5.center) -- (v6.center) -- (v2.center);
\draw (v1) edge (v2);
\draw (v1) node[below right,scale=2] {$x$};
\draw (v2) node[above right,scale=2] {$x$};
\draw (-1.5,0) node[above left,scale=2]{$p$};
\draw (0,1.5) .. controls (-1,1.5) and (-1.5,1) .. (-1.5,0);
\draw (0,1.5) circle [radius=0.5] node[scale=2]{$a$};
\end{tikzpicture}
\end{document}
Can I clip the right/left part of a path ? That is, give the x-x line and ask to have the left part be blue, the right part be yellow, without having to compute the boundaries.
Is there a smarter way to do things ?
center
and using anchors with them is pointless.