3

I have the following curve from a previous thread:

\documentclass{article}
\usepackage{tikz}

\begin{document}
    
\begin{tikzpicture}
    \draw [cyan,line width=1mm] (0,0) .. controls (3,5) and (6,-1) .. (7,2)    ;
\end{tikzpicture}

\end{document}

enter image description here

I would like to add 2 effects (separately):

  1. I would like to "blur" the curve (i.e., to convolve the image with a 2-D Gaussian kernel).
  2. I would like to add some shading. More precisely I would like the colour of the curve to progressively become white (or preferably transparent, but white will do) in some areas.

I would some documentation for the shading library but nothing for curves (only areas).

Many thanks in advance

4

2 Answers 2

2

Using fade-no-fill.sty from Hotschke and Andrew Stacey for the shading and percusse's method for blurring, a shaded and blurred path can be drawn.

shaded and blurred cyan-magenta path

\documentclass{standalone}
\usepackage{tikz}
% ateb: https://tex.stackexchange.com/a/700367/
% fade-no-fill o:
% ateb Hotschke updated gan Andrew Stacey: https://tex.stackexchange.com/a/567029/
%\url{https://tex.stackexchange.com/a/327713/86}
\usepackage{fade-no-fill}
\begin{document}
    
\begin{tikzpicture}
  \foreach \x [evaluate=\x as \xc using 0.5*100*ln(10/\x)] in {10,9.9,...,1}{
    \path [fade path but don't fill={line width=\x*1pt,transparent!0}{left color=cyan!\xc,right color=magenta!\xc}] (0,0) .. controls (3,5) and (6,-1) .. (7,2)    ;
  }
\end{tikzpicture}

\end{document}

Note that you would not want to use this too often as it is s-l-l-o-o-o-w.

Edit

The code works OK for me in Beamer, too.

\documentclass{beamer}
\usepackage{tikz}
% ateb: https://tex.stackexchange.com/a/700367/
% fade-no-fill o:
% ateb Hotschke updated gan Andrew Stacey: https://tex.stackexchange.com/a/567029/
%\url{https://tex.stackexchange.com/a/327713/86}
\usepackage{fade-no-fill}
\begin{document}
\begin{frame}
  \begin{tikzpicture}
    \foreach \x [evaluate=\x as \xc using 0.5*100*ln(10/\x)] in {10,9.9,...,1}{
      \path [fade path but don't fill={line width=\x*1pt,transparent!0}{left color=cyan!\xc,right color=magenta!\xc}] (0,0) .. controls (3,5) and (6,-1) .. (7,2)    ;
    }
  \end{tikzpicture}
\end{frame}

\end{document}

curve shown in Beamer slide

Note that I'm using the second version of the sty from https://tex.stackexchange.com/a/567029/ i.e. the updated one added in July 2021 by Andrew Stacey, modified in light of changes to spath3.

5
  • Or if you do want to use many, you may be interested in memoize ... ;).
    – cfr
    Nov 3, 2023 at 21:42
  • Thanks @cfr. I created a modified version of fade-no-fill.sty file but using spath3 as spath is depreciated, using tex.stackexchange.com/questions/337898/… but unfortunately I get a lot of errors when compiling
    – Andros
    Nov 4, 2023 at 9:15
  • I worked it out on a standalone document, but for some reason it produces a blank image in my Beamer document
    – Andros
    Nov 4, 2023 at 13:49
  • @Andros I used the sty from tex.stackexchange.com/a/567029. The second one in that answer - not the first. That uses spath3 and was updated in July 2021.
    – cfr
    Nov 4, 2023 at 14:42
  • @Andros I've added the code and output for my Beamer test. See edit above.
    – cfr
    Nov 4, 2023 at 14:48
1

So I have implemented that solution from here

\begin{tikzpicture}
    \foreach \x[evaluate={\xc=0.5*100*ln(10/\x);}] in {10,9.9,...,1}{
        \draw [draw=cyan!\xc,line width=\x*1pt] (0,0) .. controls (3,5) and (6,-1) .. (7,2)    ;
    }
\end{tikzpicture}

which produce this acceptable output. blurred curve However I don't understand why using cyan!\xc instead of draw=cyan!\xc returns

Package color Error: Argument `1.02026' not in range [0,1]. ^^I} 

as \xc is supposed to be between 0 and 100...

I still have no solution for shading the curve...

1
  • I think it is trying to interpret the colour using a different colour model. Why it is doing that I'm not sure.
    – cfr
    Nov 3, 2023 at 21:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .