Consider the following MWE:
\documentclass[border=5pt,tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\foreach \x in {1,1.2,...,3}
{
\pgfmathsetmacro{\a}{10*\x}
\fill[blue!\a,shift={(-1,-2)}] (\x,-.3) rectangle (\x+1,2.3);
}
\fill[white] (0,0) .. controls (1,1) and (1.5,-1) .. (3,0) -- (3,.4) -- (0,.4) -- cycle;
\fill[white] (0,-2) .. controls (1,-1) and (1.5,-3) .. (3,-2) -- (3,-2.3) -- (0,-2.3) -- cycle;
\draw (0,0) .. controls (1,1) and (1.5,-1) .. (3,0);
\draw (0,-2) .. controls (1,-1) and (1.5,-3) .. (3,-2);
\begin{scope}[yshift=4cm]
\foreach \x in {0,.1,...,.8}
{
\pgfmathsetmacro{\a}{\x*40}
\fill[blue!\a] ($(0,0)!\x!(2,.5)$) -- ([yshift=-1cm]$(0,0)!\x!(2,.5)$) -- ([yshift=-1cm,xshift=.5cm]$(0,0)!\x!(2,.5)$) -- ([yshift=.11cm,xshift=.5cm]$(0,0)!\x!(2,.5)$);
}
\draw[shorten >=.1cm,thick] (0,0) -- (2,.5);
\begin{scope}[shift={(0,-2)}]
\foreach \x in {0,.1,...,.9}
{
\pgfmathsetmacro{\a}{\x*40}
\pgfmathsetmacro{\b}{\x+.1}
\fill[blue!\a] ($(0,0)!\x!(2,.5)$) -- ([yshift=-1cm]$(0,0)!\x!(2,.5)$) -- ($(0,-1)!\x!(2,-.5)$) -- ($(0,-1)!\b!(2,-.5)$) -- ($(0,0)!\b!(2,.5)$) -- cycle;
}
\draw[shorten >=.2cm,thick] (0,0) -- (2,.5);
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}
As you can see in the above part (see the first image) I can \usetikzlibrary{calc}
to achieve a convient coloring of the areas. But in the above part (see second image) I had to manually overlay areas which may not get "painted". I tried here the calc
library, too, but it calulates the points just as the are at a straight line, not as a curve with some band angle(s). My question is: How can I use the calc
library to have a more ellegant code for the second part?
\fill[blue!\a] ($(0,0)!\x!(2,.5)$) -- ++ (0,-1) -- ++ ($(0,0)!0.1!(2,.5)$) -- ++(0,1) -- cycle;
. I really think it is so much simpler with relative coordinates. – user121799 Aug 24 '18 at 17:50