Smarter gradients: how to make TikZ “shade” to follow the actual shape?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












Consider the following MWE:



documentclassarticle
usepackagetikz
begindocument

begintikzpicture
shade[top color=yellow,bottom color=green] (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
endtikzpicture
enddocument


whose output is



enter image description here



As you can see, the top color=yellow only affects the upper tips/vertices of the shape. I was expecting something of the form



enter image description here



where I apologise for the crappy paint job. In any case, I wanted the shading to follow the shape of the object: that the upper edge is yellow, the bottom one is green, and that the gradient affects the whole figure, and not only the upper vertices.



How can this be done (in TikZ)? It would be nice to understand the general case but, if it's not possible, the shape above suffices for my purposes.










share|improve this question







New contributor




DGD is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    2
    down vote

    favorite












    Consider the following MWE:



    documentclassarticle
    usepackagetikz
    begindocument

    begintikzpicture
    shade[top color=yellow,bottom color=green] (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
    endtikzpicture
    enddocument


    whose output is



    enter image description here



    As you can see, the top color=yellow only affects the upper tips/vertices of the shape. I was expecting something of the form



    enter image description here



    where I apologise for the crappy paint job. In any case, I wanted the shading to follow the shape of the object: that the upper edge is yellow, the bottom one is green, and that the gradient affects the whole figure, and not only the upper vertices.



    How can this be done (in TikZ)? It would be nice to understand the general case but, if it's not possible, the shape above suffices for my purposes.










    share|improve this question







    New contributor




    DGD is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      Consider the following MWE:



      documentclassarticle
      usepackagetikz
      begindocument

      begintikzpicture
      shade[top color=yellow,bottom color=green] (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
      endtikzpicture
      enddocument


      whose output is



      enter image description here



      As you can see, the top color=yellow only affects the upper tips/vertices of the shape. I was expecting something of the form



      enter image description here



      where I apologise for the crappy paint job. In any case, I wanted the shading to follow the shape of the object: that the upper edge is yellow, the bottom one is green, and that the gradient affects the whole figure, and not only the upper vertices.



      How can this be done (in TikZ)? It would be nice to understand the general case but, if it's not possible, the shape above suffices for my purposes.










      share|improve this question







      New contributor




      DGD is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      Consider the following MWE:



      documentclassarticle
      usepackagetikz
      begindocument

      begintikzpicture
      shade[top color=yellow,bottom color=green] (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
      endtikzpicture
      enddocument


      whose output is



      enter image description here



      As you can see, the top color=yellow only affects the upper tips/vertices of the shape. I was expecting something of the form



      enter image description here



      where I apologise for the crappy paint job. In any case, I wanted the shading to follow the shape of the object: that the upper edge is yellow, the bottom one is green, and that the gradient affects the whole figure, and not only the upper vertices.



      How can this be done (in TikZ)? It would be nice to understand the general case but, if it's not possible, the shape above suffices for my purposes.







      tikz-pgf






      share|improve this question







      New contributor




      DGD is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      DGD is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      DGD is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 4 hours ago









      DGD

      112




      112




      New contributor




      DGD is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      DGD is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      DGD is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote













          The shades available are only radial or linear, but you can solve this using a clipped area and draw the shape many times shifted by some value in the y coordinate while the color is changed. Also you can use many clipped shapes to draw another elements outside if you put it in a scope.



          RESULT:



          enter image description here



          MWE:



          documentclass[tikz,border=20pt]standalone
          begindocument
          begintikzpicture

          beginscope
          clip
          (-2,0)
          to[out=-90,in=180] (0,-2)
          to[out=0,in=-90] (2,0)
          to[out=-90-35,in=0](0,-.7)
          to[out=180,in=-55] (-2,0);

          foreach x [evaluate=x as xn using x*4] in 1,...,25
          fill[green!xn!yellow,yshift=2-x]
          (-2,0)
          to[out=-90,in=180] (0,-2)
          to[out=0,in=-90] (2,0)
          to[out=-90-35,in=0](0,-.7)
          to[out=180,in=-55] (-2,0);

          endscope
          shade[top color=yellow,bottom color=red](1,0) circle (0.2);
          endtikzpicture
          enddocument





          share|improve this answer



























            up vote
            2
            down vote













            Welcome to TeX.SE! The answer is, AFAIK, that there is no predefined way of doing this. However, you can cheat and use some of the options that come with the shadings library together with clip to do something along the lines you are suggesting.



            documentclassarticle
            usepackagetikz
            usetikzlibraryshadings
            begindocument
            begintikzpicture
            clip (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
            shade[inner color=yellow,outer color=green] (-3,0.8) arc(180:360:3);
            endtikzpicture
            enddocument


            enter image description here



            I could not resist adding something more fancy based on cfr's fancy radial shading. This also is meant to illustrate how one can customize shading.



            documentclass[border=3.14mm,x11names,dvipsnames,svgnames]standalone
            usepackagetikz
            usetikzlibraryshadings
            pgfdeclareradialshading[fradialcolour1,fradialcolour2,fradialcolour3]fncyradialpgfpoint00% manual 1082-1083; later - shading is assumed to be 100bp diameter ??
            color(0)=(fradialcolour1);
            color(20bp)=(fradialcolour2);
            color(40bp)=(fradialcolour3);
            color(50bp)=(fradialcolour3)

            tikzset%
            fradial/.code=%
            tikzset%
            fancy radial/.cd,
            shading=fncyradial,
            #1

            ,
            fancy radial/.search also=/tikz,
            fancy radial/.cd,
            fancy radial inner colour/.code=
            colorletfradialcolour1#1
            ,
            fancy radial mid colour/.code=
            colorletfradialcolour2#1
            ,
            fancy radial outer colour/.code=
            colorletfradialcolour3#1
            ,
            fancy radial inner colour=black,
            fancy radial outer colour=black,
            fancy radial mid colour=white,
            inner color/.style=
            fancy radial inner colour=#1,
            ,
            outer color/.style=
            fancy radial outer colour=#1,
            ,
            mid color/.style=
            fancy radial mid colour=#1,
            ,

            begindocument
            begintikzpicture
            clip (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
            shade[fradial=inner color=yellow, outer color=green, mid color=yellow!70!green] (-3,1) arc(180:360:3);
            endtikzpicture
            enddocument


            enter image description here



            And, of course, there are all the advanced options described in section 109 of the pgfmanual. In principle you could try to use pgfsetadditionalshadetransform but this is major effort and also won't lead to a universal solution. I'd also like to mention that it seems nontrivial to implement nonlinear transformations here (see here). If this problem was not there, one may be able to construct a general solution in a similar way as the bending library works, i.e. define a nonlinear transformation from a path.






            share|improve this answer






















              Your Answer







              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "85"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );






              DGD is a new contributor. Be nice, and check out our Code of Conduct.









               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f453379%2fsmarter-gradients-how-to-make-tikz-shade-to-follow-the-actual-shape%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote













              The shades available are only radial or linear, but you can solve this using a clipped area and draw the shape many times shifted by some value in the y coordinate while the color is changed. Also you can use many clipped shapes to draw another elements outside if you put it in a scope.



              RESULT:



              enter image description here



              MWE:



              documentclass[tikz,border=20pt]standalone
              begindocument
              begintikzpicture

              beginscope
              clip
              (-2,0)
              to[out=-90,in=180] (0,-2)
              to[out=0,in=-90] (2,0)
              to[out=-90-35,in=0](0,-.7)
              to[out=180,in=-55] (-2,0);

              foreach x [evaluate=x as xn using x*4] in 1,...,25
              fill[green!xn!yellow,yshift=2-x]
              (-2,0)
              to[out=-90,in=180] (0,-2)
              to[out=0,in=-90] (2,0)
              to[out=-90-35,in=0](0,-.7)
              to[out=180,in=-55] (-2,0);

              endscope
              shade[top color=yellow,bottom color=red](1,0) circle (0.2);
              endtikzpicture
              enddocument





              share|improve this answer
























                up vote
                2
                down vote













                The shades available are only radial or linear, but you can solve this using a clipped area and draw the shape many times shifted by some value in the y coordinate while the color is changed. Also you can use many clipped shapes to draw another elements outside if you put it in a scope.



                RESULT:



                enter image description here



                MWE:



                documentclass[tikz,border=20pt]standalone
                begindocument
                begintikzpicture

                beginscope
                clip
                (-2,0)
                to[out=-90,in=180] (0,-2)
                to[out=0,in=-90] (2,0)
                to[out=-90-35,in=0](0,-.7)
                to[out=180,in=-55] (-2,0);

                foreach x [evaluate=x as xn using x*4] in 1,...,25
                fill[green!xn!yellow,yshift=2-x]
                (-2,0)
                to[out=-90,in=180] (0,-2)
                to[out=0,in=-90] (2,0)
                to[out=-90-35,in=0](0,-.7)
                to[out=180,in=-55] (-2,0);

                endscope
                shade[top color=yellow,bottom color=red](1,0) circle (0.2);
                endtikzpicture
                enddocument





                share|improve this answer






















                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  The shades available are only radial or linear, but you can solve this using a clipped area and draw the shape many times shifted by some value in the y coordinate while the color is changed. Also you can use many clipped shapes to draw another elements outside if you put it in a scope.



                  RESULT:



                  enter image description here



                  MWE:



                  documentclass[tikz,border=20pt]standalone
                  begindocument
                  begintikzpicture

                  beginscope
                  clip
                  (-2,0)
                  to[out=-90,in=180] (0,-2)
                  to[out=0,in=-90] (2,0)
                  to[out=-90-35,in=0](0,-.7)
                  to[out=180,in=-55] (-2,0);

                  foreach x [evaluate=x as xn using x*4] in 1,...,25
                  fill[green!xn!yellow,yshift=2-x]
                  (-2,0)
                  to[out=-90,in=180] (0,-2)
                  to[out=0,in=-90] (2,0)
                  to[out=-90-35,in=0](0,-.7)
                  to[out=180,in=-55] (-2,0);

                  endscope
                  shade[top color=yellow,bottom color=red](1,0) circle (0.2);
                  endtikzpicture
                  enddocument





                  share|improve this answer












                  The shades available are only radial or linear, but you can solve this using a clipped area and draw the shape many times shifted by some value in the y coordinate while the color is changed. Also you can use many clipped shapes to draw another elements outside if you put it in a scope.



                  RESULT:



                  enter image description here



                  MWE:



                  documentclass[tikz,border=20pt]standalone
                  begindocument
                  begintikzpicture

                  beginscope
                  clip
                  (-2,0)
                  to[out=-90,in=180] (0,-2)
                  to[out=0,in=-90] (2,0)
                  to[out=-90-35,in=0](0,-.7)
                  to[out=180,in=-55] (-2,0);

                  foreach x [evaluate=x as xn using x*4] in 1,...,25
                  fill[green!xn!yellow,yshift=2-x]
                  (-2,0)
                  to[out=-90,in=180] (0,-2)
                  to[out=0,in=-90] (2,0)
                  to[out=-90-35,in=0](0,-.7)
                  to[out=180,in=-55] (-2,0);

                  endscope
                  shade[top color=yellow,bottom color=red](1,0) circle (0.2);
                  endtikzpicture
                  enddocument






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 3 hours ago









                  J Leon V.

                  7,030528




                  7,030528




















                      up vote
                      2
                      down vote













                      Welcome to TeX.SE! The answer is, AFAIK, that there is no predefined way of doing this. However, you can cheat and use some of the options that come with the shadings library together with clip to do something along the lines you are suggesting.



                      documentclassarticle
                      usepackagetikz
                      usetikzlibraryshadings
                      begindocument
                      begintikzpicture
                      clip (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
                      shade[inner color=yellow,outer color=green] (-3,0.8) arc(180:360:3);
                      endtikzpicture
                      enddocument


                      enter image description here



                      I could not resist adding something more fancy based on cfr's fancy radial shading. This also is meant to illustrate how one can customize shading.



                      documentclass[border=3.14mm,x11names,dvipsnames,svgnames]standalone
                      usepackagetikz
                      usetikzlibraryshadings
                      pgfdeclareradialshading[fradialcolour1,fradialcolour2,fradialcolour3]fncyradialpgfpoint00% manual 1082-1083; later - shading is assumed to be 100bp diameter ??
                      color(0)=(fradialcolour1);
                      color(20bp)=(fradialcolour2);
                      color(40bp)=(fradialcolour3);
                      color(50bp)=(fradialcolour3)

                      tikzset%
                      fradial/.code=%
                      tikzset%
                      fancy radial/.cd,
                      shading=fncyradial,
                      #1

                      ,
                      fancy radial/.search also=/tikz,
                      fancy radial/.cd,
                      fancy radial inner colour/.code=
                      colorletfradialcolour1#1
                      ,
                      fancy radial mid colour/.code=
                      colorletfradialcolour2#1
                      ,
                      fancy radial outer colour/.code=
                      colorletfradialcolour3#1
                      ,
                      fancy radial inner colour=black,
                      fancy radial outer colour=black,
                      fancy radial mid colour=white,
                      inner color/.style=
                      fancy radial inner colour=#1,
                      ,
                      outer color/.style=
                      fancy radial outer colour=#1,
                      ,
                      mid color/.style=
                      fancy radial mid colour=#1,
                      ,

                      begindocument
                      begintikzpicture
                      clip (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
                      shade[fradial=inner color=yellow, outer color=green, mid color=yellow!70!green] (-3,1) arc(180:360:3);
                      endtikzpicture
                      enddocument


                      enter image description here



                      And, of course, there are all the advanced options described in section 109 of the pgfmanual. In principle you could try to use pgfsetadditionalshadetransform but this is major effort and also won't lead to a universal solution. I'd also like to mention that it seems nontrivial to implement nonlinear transformations here (see here). If this problem was not there, one may be able to construct a general solution in a similar way as the bending library works, i.e. define a nonlinear transformation from a path.






                      share|improve this answer


























                        up vote
                        2
                        down vote













                        Welcome to TeX.SE! The answer is, AFAIK, that there is no predefined way of doing this. However, you can cheat and use some of the options that come with the shadings library together with clip to do something along the lines you are suggesting.



                        documentclassarticle
                        usepackagetikz
                        usetikzlibraryshadings
                        begindocument
                        begintikzpicture
                        clip (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
                        shade[inner color=yellow,outer color=green] (-3,0.8) arc(180:360:3);
                        endtikzpicture
                        enddocument


                        enter image description here



                        I could not resist adding something more fancy based on cfr's fancy radial shading. This also is meant to illustrate how one can customize shading.



                        documentclass[border=3.14mm,x11names,dvipsnames,svgnames]standalone
                        usepackagetikz
                        usetikzlibraryshadings
                        pgfdeclareradialshading[fradialcolour1,fradialcolour2,fradialcolour3]fncyradialpgfpoint00% manual 1082-1083; later - shading is assumed to be 100bp diameter ??
                        color(0)=(fradialcolour1);
                        color(20bp)=(fradialcolour2);
                        color(40bp)=(fradialcolour3);
                        color(50bp)=(fradialcolour3)

                        tikzset%
                        fradial/.code=%
                        tikzset%
                        fancy radial/.cd,
                        shading=fncyradial,
                        #1

                        ,
                        fancy radial/.search also=/tikz,
                        fancy radial/.cd,
                        fancy radial inner colour/.code=
                        colorletfradialcolour1#1
                        ,
                        fancy radial mid colour/.code=
                        colorletfradialcolour2#1
                        ,
                        fancy radial outer colour/.code=
                        colorletfradialcolour3#1
                        ,
                        fancy radial inner colour=black,
                        fancy radial outer colour=black,
                        fancy radial mid colour=white,
                        inner color/.style=
                        fancy radial inner colour=#1,
                        ,
                        outer color/.style=
                        fancy radial outer colour=#1,
                        ,
                        mid color/.style=
                        fancy radial mid colour=#1,
                        ,

                        begindocument
                        begintikzpicture
                        clip (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
                        shade[fradial=inner color=yellow, outer color=green, mid color=yellow!70!green] (-3,1) arc(180:360:3);
                        endtikzpicture
                        enddocument


                        enter image description here



                        And, of course, there are all the advanced options described in section 109 of the pgfmanual. In principle you could try to use pgfsetadditionalshadetransform but this is major effort and also won't lead to a universal solution. I'd also like to mention that it seems nontrivial to implement nonlinear transformations here (see here). If this problem was not there, one may be able to construct a general solution in a similar way as the bending library works, i.e. define a nonlinear transformation from a path.






                        share|improve this answer
























                          up vote
                          2
                          down vote










                          up vote
                          2
                          down vote









                          Welcome to TeX.SE! The answer is, AFAIK, that there is no predefined way of doing this. However, you can cheat and use some of the options that come with the shadings library together with clip to do something along the lines you are suggesting.



                          documentclassarticle
                          usepackagetikz
                          usetikzlibraryshadings
                          begindocument
                          begintikzpicture
                          clip (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
                          shade[inner color=yellow,outer color=green] (-3,0.8) arc(180:360:3);
                          endtikzpicture
                          enddocument


                          enter image description here



                          I could not resist adding something more fancy based on cfr's fancy radial shading. This also is meant to illustrate how one can customize shading.



                          documentclass[border=3.14mm,x11names,dvipsnames,svgnames]standalone
                          usepackagetikz
                          usetikzlibraryshadings
                          pgfdeclareradialshading[fradialcolour1,fradialcolour2,fradialcolour3]fncyradialpgfpoint00% manual 1082-1083; later - shading is assumed to be 100bp diameter ??
                          color(0)=(fradialcolour1);
                          color(20bp)=(fradialcolour2);
                          color(40bp)=(fradialcolour3);
                          color(50bp)=(fradialcolour3)

                          tikzset%
                          fradial/.code=%
                          tikzset%
                          fancy radial/.cd,
                          shading=fncyradial,
                          #1

                          ,
                          fancy radial/.search also=/tikz,
                          fancy radial/.cd,
                          fancy radial inner colour/.code=
                          colorletfradialcolour1#1
                          ,
                          fancy radial mid colour/.code=
                          colorletfradialcolour2#1
                          ,
                          fancy radial outer colour/.code=
                          colorletfradialcolour3#1
                          ,
                          fancy radial inner colour=black,
                          fancy radial outer colour=black,
                          fancy radial mid colour=white,
                          inner color/.style=
                          fancy radial inner colour=#1,
                          ,
                          outer color/.style=
                          fancy radial outer colour=#1,
                          ,
                          mid color/.style=
                          fancy radial mid colour=#1,
                          ,

                          begindocument
                          begintikzpicture
                          clip (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
                          shade[fradial=inner color=yellow, outer color=green, mid color=yellow!70!green] (-3,1) arc(180:360:3);
                          endtikzpicture
                          enddocument


                          enter image description here



                          And, of course, there are all the advanced options described in section 109 of the pgfmanual. In principle you could try to use pgfsetadditionalshadetransform but this is major effort and also won't lead to a universal solution. I'd also like to mention that it seems nontrivial to implement nonlinear transformations here (see here). If this problem was not there, one may be able to construct a general solution in a similar way as the bending library works, i.e. define a nonlinear transformation from a path.






                          share|improve this answer














                          Welcome to TeX.SE! The answer is, AFAIK, that there is no predefined way of doing this. However, you can cheat and use some of the options that come with the shadings library together with clip to do something along the lines you are suggesting.



                          documentclassarticle
                          usepackagetikz
                          usetikzlibraryshadings
                          begindocument
                          begintikzpicture
                          clip (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
                          shade[inner color=yellow,outer color=green] (-3,0.8) arc(180:360:3);
                          endtikzpicture
                          enddocument


                          enter image description here



                          I could not resist adding something more fancy based on cfr's fancy radial shading. This also is meant to illustrate how one can customize shading.



                          documentclass[border=3.14mm,x11names,dvipsnames,svgnames]standalone
                          usepackagetikz
                          usetikzlibraryshadings
                          pgfdeclareradialshading[fradialcolour1,fradialcolour2,fradialcolour3]fncyradialpgfpoint00% manual 1082-1083; later - shading is assumed to be 100bp diameter ??
                          color(0)=(fradialcolour1);
                          color(20bp)=(fradialcolour2);
                          color(40bp)=(fradialcolour3);
                          color(50bp)=(fradialcolour3)

                          tikzset%
                          fradial/.code=%
                          tikzset%
                          fancy radial/.cd,
                          shading=fncyradial,
                          #1

                          ,
                          fancy radial/.search also=/tikz,
                          fancy radial/.cd,
                          fancy radial inner colour/.code=
                          colorletfradialcolour1#1
                          ,
                          fancy radial mid colour/.code=
                          colorletfradialcolour2#1
                          ,
                          fancy radial outer colour/.code=
                          colorletfradialcolour3#1
                          ,
                          fancy radial inner colour=black,
                          fancy radial outer colour=black,
                          fancy radial mid colour=white,
                          inner color/.style=
                          fancy radial inner colour=#1,
                          ,
                          outer color/.style=
                          fancy radial outer colour=#1,
                          ,
                          mid color/.style=
                          fancy radial mid colour=#1,
                          ,

                          begindocument
                          begintikzpicture
                          clip (-2,0) to[out=-90,in=180] (0,-2) to[out=0,in=-90] (2,0) to[out=-90-35,in=0] (0,-.7) to[out=180,in=-55] (-2,0);
                          shade[fradial=inner color=yellow, outer color=green, mid color=yellow!70!green] (-3,1) arc(180:360:3);
                          endtikzpicture
                          enddocument


                          enter image description here



                          And, of course, there are all the advanced options described in section 109 of the pgfmanual. In principle you could try to use pgfsetadditionalshadetransform but this is major effort and also won't lead to a universal solution. I'd also like to mention that it seems nontrivial to implement nonlinear transformations here (see here). If this problem was not there, one may be able to construct a general solution in a similar way as the bending library works, i.e. define a nonlinear transformation from a path.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 1 hour ago

























                          answered 4 hours ago









                          marmot

                          61.8k466134




                          61.8k466134




















                              DGD is a new contributor. Be nice, and check out our Code of Conduct.









                               

                              draft saved


                              draft discarded


















                              DGD is a new contributor. Be nice, and check out our Code of Conduct.












                              DGD is a new contributor. Be nice, and check out our Code of Conduct.











                              DGD is a new contributor. Be nice, and check out our Code of Conduct.













                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f453379%2fsmarter-gradients-how-to-make-tikz-shade-to-follow-the-actual-shape%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Comments

                              Popular posts from this blog

                              Long meetings (6-7 hours a day): Being “babysat” by supervisor

                              Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                              Confectionery