2

Part of the radialshading should be cut out of it. With this \clip(?)ed part I want to fill the \predefined node shape (here: \node maerz). Sorry for my english.

The \shade works for two colors (here: violet black) but for me not manageable. Contrary at first the use of \pgfdeclareradialshading in pgfman301a, p.1082. But I cannot replace the \shade[inner colo and so on] before the "let" with \pgfuseshading{sphere}. Yes, both are different constructs, therefore syntax invalid. But I have the feeling the wished result lies before my eyes but i cannot work it out.

Is there anyone who could help?

Of course the radialshading must be extended to the wanted radius (s.code: pgf declaration of radial shading). The point is: cut out, fill with the outcutted shade the \node maerz from sector center to arc center.

\documentclass[margin=100pt]{standalone}
\usepackage{tikz}     

\makeatletter
% from https://tex.stackexchange.com/a/127045/121799
\tikzset{use path/.code=\tikz@addmode{\pgfsyssoftpath@setcurrentpath#1}}
\makeatother

\usetikzlibrary{calc,shapes.geometric,backgrounds,fadings}

\tikzfading[name=fade in,inner color=transparent!10,outer color=transparent!10]

\pgfdeclareradialshading[fradialcolour1,fradialcolour2,fradialcolour3]
                     {fncyradial}{\pgfpoint{0}{0}}
                     {% manual 1082-1083; 
                      %later - shading is assumed to be 100bp diameter ??
                      color(0)=(fradialcolour1);
                      color(20bp)=(fradialcolour2);
                      color(40bp)=(fradialcolour3);
                      color(50bp)=(fradialcolour3)
                     }
\tikzset{% https://tex.stackexchange.com/a/372682/121799
fradial/.code={%
    \tikzset{%
        fancy radial/.cd,
        shading=fncyradial,
        #1
    }
},%end fradial/.co...
fancy radial/.search also={/tikz},
fancy radial/.cd,
%
fancy radial inner colour/.code={\colorlet{fradialcolour1}{#1}},
fancy radial mid colour/.code={\colorlet{fradialcolour2}{#1}},
fancy radial outer colour/.code={\colorlet{fradialcolour3}{#1}},
%
fancy radial inner colour=black,
fancy radial outer colour=red,
fancy radial mid colour=violet,
inner color/.style={
    fancy radial inner colour=#1,
},
outer color/.style={
    fancy radial outer colour=#1,
},
mid color/.style={
    fancy radial mid colour=#1,
},
}%end tikzset

\begin{document}  

\begin{tikzpicture}[scale=1.0,transform shape] 

\tikzset{shape circlesec/.style={
        draw,
        line width=0.1pt,
        inner xsep=0pt,
        inner ysep=0pt,
    } 
}%end tikzset


\node [name=maerz,
       save path=\pathA,
       shape=circular sector, 
       style=shape circlesec,
       inner sep=0cm,
       circular sector angle=30,
       shape border uses incircle,
       shape border rotate=-165,
       anchor=sector center,inner sep=-2mm,%
       minimum size = 6.6cm,%has an effect if the original size was smaller
      ] 
   (maerz) at (0,0) {};

    \pgfdeclareradialshading{sphere}%shading name
                            {\pgfpoint{0}{0}}%center point pgfman301a,p.1083
                            {rgb(0.00cm)=(1.00,0.00,0.00); %color specification
                             rgb(1.70cm)=(0.60,1.00,0.00);
                             rgb(2.50cm)=(0.30,1.60,1.00);
                             rgb(3.00cm)=(0.00,0.30,1.50) %extent of the circle
                            }
   \begin{scope}[on background layer]
      \pgfuseshading{sphere};
      % HOW integrate the \node name=maerz here instaed of shade???
      % changing the \shade [option] with \pfgdeclareradialshading{sphere} doesn't work
      \clip[use path=\pathA];
      \shade[inner color=black,% third color not usable?
             outer color=violet,
             %mid color=green,%not usable?
             path fading=fade in
         ] %the lengths here i want use for the \node nmae=maerz
         let \p1=($(maerz.arc center)-(maerz.sector center)$),
             \n1={veclen(\y1,\x1)}
              in (maerz.sector center) circle (\n1);
\end{scope}

\foreach \anchor/\placement in
   {arc center/right, sector center/below left}
      \draw[shift=(maerz.\anchor)] plot[mark=x] coordinates{(0,0)}
           node[\placement] {\scriptsize\texttt{(maerz.\anchor)}};  

\draw let \p1=($(maerz.north)-(maerz.sector center)$),\n1={int(1+\y1*1pt/1cm)}%
   in
   \pgfextra{\pgfmathtruncatemacro{\xmax}{\n1}
             \pgfmathtruncatemacro{\nextx}{\xmax-1}
            }%end pgfextra code
   foreach \x in {-\xmax,-\nextx,...,\xmax}
      {(\x,1pt) -- (\x,-1pt) node[anchor=north,font=\tiny]{ $\x$} } 
   foreach \y in {-\xmax,-\nextx,...,\xmax}
      {(1pt,\y) -- (-1pt,\y) node[anchor=east,font=\tiny]{($\y$)}};

\end{tikzpicture} 
\end{document}

part of circle should be a node of shape circular sector

4

After some amount of trial and error I found a way to implement the shading in the path picture. No more calc and so on, everything is now a simple style of the type

       shade radial={
        shade radial color={1}{black},
        shade radial color={2}{green},
        shade radial color={3}{blue},
        shade radial color={4}{red}
        },

which you can add to the node.

enter image description here

(The shading is called color four radial instead of four color radial to acknowledge pioneering work by cfr.)

MWE:

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.geometric}
\tikzset{shade radial/.code={%
        \tikzset{%
          color four radial/.cd,% I know "four color radial" sounds better but cfr should be acknowledged here
          #1,
          cfradial
        }},
color four radial/.cd,  
shade radial color/.code n args={2}{\colorlet{cfradialcolor#1}{#2}},
shade radial color={1}{black},
shade radial color={2}{black},
shade radial color={3}{white},
shade radial color={4}{white},
cfradial/.style={/tikz/path picture={
\xdef\radius{\radius}
\pgfmathsetmacro{\rone}{0.6*\radius}
\pgfmathsetmacro{\rtwo}{0.8*\radius}
\pgfdeclareradialshading[cfradialcolor1,cfradialcolor2,cfradialcolor3,cfradialcolor4]{cfradial}%shading name see pgfmanual 3.01a, p. 1083
                            {\centerpoint}%center point 
                            {color(0pt)=(cfradialcolor1); %color specifications
                             color(\rone pt)=(cfradialcolor2);
                             color(\rtwo pt)=(cfradialcolor3);
                             color(\radius)=(cfradialcolor4) %
                            }
\typeout{\radius,\rone,\rtwo}
\pgfuseshading{cfradial}
}}}

\begin{document}  
\begin{tikzpicture}
\tikzset{shape circlesec/.style={
        draw,
        line width=0.1pt,
        inner xsep=0pt,
        inner ysep=0pt,
    } 
}
\node [shape=circular sector, 
       style=shape circlesec,
       inner sep=0cm,
       shade radial={
        shade radial color={1}{black},
        shade radial color={2}{green},
        shade radial color={3}{blue},
        shade radial color={4}{red}
        },
       circular sector angle=30,
       shape border uses incircle,
       shape border rotate=-165,
       anchor=sector center,inner sep=-2mm,%
       minimum size = 6.6cm,%has an effect if the original size was smaller
      ] 
   (maerz) at (0,0) {};
\end{tikzpicture} 
\end{document}

Old answer: Here is an attempt to answer this nice question. I think it is a very clever idea to use \pgfdeclareradialshading in the way you propose. All I did was to clean up a bit and to write a pgfkeys code that declares the shading based on some input that can be extracted e.g. via calc. I also kicked out elements that may not be essential to the problem like the grid.

\documentclass[margin=100pt]{standalone}
\usepackage{tikz}     
\makeatletter
% from https://tex.stackexchange.com/a/127045/121799
\tikzset{use path/.code=\tikz@addmode{\pgfsyssoftpath@setcurrentpath#1}}
\makeatother
\usetikzlibrary{calc,shapes.geometric,backgrounds,fadings}
\tikzset{my radial shader/.code args={#1 with radius #2}{
\pgfmathsetmacro{\rone}{0.6*#2}
\pgfmathsetmacro{\rtwo}{0.8*#2}
\typeout{#1:\rone,#2}
\pgfdeclareradialshading{#1}%shading name
                            {\pgfpoint{0}{0}}%center point pgfman301a,p.1083
                            {rgb(0pt)=(1.00,0.00,0.00); %color specification
                             rgb(\rone pt)=(0.60,1.00,0.00);
                             rgb(\rtwo pt)=(0.30,1.60,1.00);
                             rgb(#2)=(0.00,0.30,1.50) %extent of the circle
                            }
}}

\begin{document}  
\begin{tikzpicture}
\tikzset{shape circlesec/.style={
        draw,
        line width=0.1pt,
        inner xsep=0pt,
        inner ysep=0pt,
    } 
}
\node [save path=\pathA,
       shape=circular sector, 
       style=shape circlesec,
       inner sep=0cm,
       circular sector angle=30,
       shape border uses incircle,
       shape border rotate=-165,
       anchor=sector center,inner sep=-2mm,%
       minimum size = 6.6cm,%has an effect if the original size was smaller
      ] 
   (maerz) at (0,0) {};

   \begin{scope}[on background layer]
   \path    let \p1=($(maerz.arc center)-(maerz.sector center)$),
             \n1={veclen(\y1,\x1)} in 
             [my radial shader={rad1 with radius \n1}];
   \clip[use path=\pathA];               
   \pgfuseshading{rad1};
   \end{scope}
\end{tikzpicture} 
\end{document}

enter image description here

I believe that this can be simplified quite a bit with path picture and so on. Yet this is something that at least works.

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.