# Problem with shadings declarations in pgf

I have no real question but rather some observations about declaring shadings in pgf.

First strange thing is that parameterless shadings are declared globally while shadings with parameters are declared locally. For instance, if one says

``````\begingroup
\endgroup
``````

then

``````\pgfuseshading{myshading1}
``````

works because `myshading1` was actually declared globally, while

``````\colorlet{mycolor}{red}
``````

does not because `myshading2` was declared locally.

However, when a shading with parameters is used, a specific instance is declared globally if not already declared. For instance, after

``````\begingroup
\colorlet{mycolor}{red}
\endgroup
``````

the shading `myshading2,1,0,0` is declared globally (red=rgb(1,0,0)), and one may use

``````\pgfuseshading{myshading2,1,0,0}
``````

although `myshading2` is not defined anymore.

Another problem is that redefining a shading with parameters is impossible or at least may produce strange results. In the following example, `myshading2` is first declared as a vertical shading and used with `mycolor=red`. Afterwards it is redeclared as a radial shading and used first with `mycolor=green` which works as expected and then with `mycolor=red` which uses falsely the vertical shading: since `myshading2,1,0,0` was already declared, it is not redefined.

``````\pgfdeclareverticalshading[mycolor]{myshading2}{1cm}{color(0cm)=(mycolor);color(1cm)=(mycolor!20)}
\colorlet{mycolor}{red}