To paint a gradient into the image, we click where we want the gradient to begin and then drag and release where we want the gradient to end. In the example above we clicked in the upper left of the image and have dragged down and will release in the lower right.

There is no selection made in this image so the gradient tool will paint the entire image. All regions before the beginning click will be pure blue in color. All regions after the release click will be pure gold yellow. The regions in between will be painted in a continuous gradient of colors in a smooth mix from blue to gold. The regions "before" and "after" the initial click and final release are defined by lines perpendicular to the line of click and drag.

The result is that all pixels in the image are painted in either blue, gold or a mix of shades from blue to gold.

The gradient tool paints a gradient based on the initial click and the final release point. These do not have to be within the image. In the example above we clicked well outside the image and then dragged right and released outside the image as well.

The transition from blue to gold will be computed over the entire range of the click and drag but only that part of the gradient that falls within the image will be painted into the image. Note that the image does not have any pure blue or gold in it since the end points of the gradient click and drag were outside of the image.

We can force the gradient to transition from foreground to background color more rapidly by clicking and dragging over a smaller distance. In the example above we have clicked and dragged upwards and slightly to the right over a small distance.

The result is a rapid transition, so rapid that it appears mostly green with most of the image painted in either blue or gold color.

When a Selection is Present

When a selection is present the gradient tool will work only within the selection. In the image above we have selected several round regions of pixels and one rectangular region.

We will switch to the border style of selection so we can see what happens inside the selection without the dense red dot selection pattern getting in the way.

We now click and drag with the gradient tool in the path indicated. Note that the points of click and release could be anywhere: there is no significance in the illustration above that the point of release happens to be within the selection in this particular example.

The result is that the gradient is computed as usual but it is painted only into those pixels that were selected.

We can disable use of selection color temporarily to see the result without selection borders. Using gradients within selections is a technique with an infinity of cool artistic possibilities.

We can take our sample bronze image and select all pixels outside the bronze monument. We use the dense dots selection style to make it clear which pixels are selected.

Once more we will switch to the border style of selection so that the red selection dots do not interfere with our view.

Let's change the foreground color to black and the background color to orange.

We now use the gradient tool from top to bottom as shown.

Viewing the result with selection color turned off, we can see that the gradient painted color from black to orange only into selected pixels. The effect is as if we see the bronze monument in front of a color gradient.

Notes

The examples above show the results of using the gradient tool when a selection is present. However, we would more frequently use such gradient effects within different images stacked in layers rather than within a selection in only one image. This would allow us, for example, to independently manipulate the "cut out" of the bronze statue in one image/layer while we adjusted the gradient in a different image/layer.

This would come in handy if we would like to clean up the "halo" of lighter pixels in the bottom part of the bronze statue. These appear as a result of sloppy selection when we selected all of the pixels outside the monument. If the bronze monument were in a different image than the "background" gradient it would be much easier to clean up the lighter pixels.

See the example Painting into the Alpha Channel for an example of how gradients are used to paint into selections as well as how they can be used to paint into just one channel of an RGBa image. Gradients are a powerful way to specify alpha transparency so partially transparent images can appear to be "feathered" into a larger image composition.