4

There's almost certainly something I'm missing here but I'd like a faded drawing to be defined and placed at various points in the picture. I can get it to look how I want, but when I place it in \begin{scope}[xshift=\x,yshift=\y] environment, the fading doesn't move with the rest of what's in the scope.

Here's a stripped-down example:

\documentclass{article}
\usepackage{tikz}
\usepackage{ifthen}
\usetikzlibrary{calc,decorations.pathmorphing,shapes}
\pgfdeclareradialshading{flameshade}{\pgfpointorigin}{color(0mm)=(pgftransparent!0);color(3mm)=(pgftransparent!40);color(8mm)=(pgftransparent!70);color(2cm)=(pgftransparent!100)}
\pgfdeclarefading{fadeflame}{\pgfuseshading{flameshade}}

\def\flame{
    \pgfsetfading{fadeflame}{\pgftransformshift{\pgfpoint{0}{-4.5}}\pgftransformxscale{0.05}\pgftransformyscale{0.08}}%
    \path(0,0) pic{flame};
}
    \tikzset{%
  flame/.pic={
    code={
        \tikzset{scale=1/10}
        \node[circle,minimum height=4, minimum width=4, fill=\fillcolour,inner sep=0,outer sep=0] at(0,-1){};

  }}}

\begin{document}

\begin{tikzpicture}
\fill[black] (-4,-3) rectangle (6,4);

\node[circle,inner sep=0, outer sep=0, draw=white,very thin] at (0,0){};

\begin{scope}[xshift=0cm, yshift=-0cm]
    \def\fillcolour{yellow}
    \flame
\end{scope}

\begin{scope}[xshift=.1cm, yshift=-0.1cm]
    \def\fillcolour{cyan}
    \flame
\end{scope}
\end{tikzpicture}
\end{document}

result of above code, heavily cropped

The white circle just indicates the origin. The yellow shaded circle looks right; when I shift it the fading stays behind (as seen from the cyan shaded circle).

  • It seems you have to give all transformations to \pgfsetfading. – Symbol 1 Jan 6 '17 at 15:42
  • @Symbol1 which implies a rewrite to draw a faded item at a particular location, rather than draw and move it. I'll have a try later on – Chris H Jan 6 '17 at 15:51
  • I just proposed an answer. This is by no means the only approach. You can try. – Symbol 1 Jan 6 '17 at 15:52
1

You may redefine \frame as follows

\def\flame{
    \pgfgettransform{\mycurrenttransform}
    \pgfsetfading{fadeflame}{
        \pgfsettransform{\mycurrenttransform}
        \pgftransformshift{\pgfpoint{0}{-4.5}}\pgftransformxscale{0.05}\pgftransformyscale{0.08}}%
    \path(0,0) pic{flame};
}

Here, \pgfgettransform will store the current transformation in \mycurrenttransform and \pgfsettransform will restore it in \pgfsetfading. That is, it now remembers where you are.

  • When I replied to your comment, your answer loaded. This could be very useful elsewhere in this drawing too. Again, I'll have a go later on. – Chris H Jan 6 '17 at 15:53

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.