Patterns and Gradients

Done using GIMP 2.8 on Kubuntu Linux 18.04 LTS

In the same area as the brushes are two more tabs, for Patterns and Gradients, and we should take a look here as our last stop before going to Layers.

Patterns

Patterns are images that are meant to be tiled. If you have as much gray hair as I do, you may remember that we tiled background images for web sites in the early days of the Web, and of course we would never do that now, would we? But while tiling is a very common use for patterns, that is not the only use. A pattern is just an image, after all, and you can use it to do things like bucket fill, paint with the clone tool, or stroke along a path.

GIMP comes with quite a few patterns “out of the box”, which are a motley assortment of images. You can select any one of them by clicking on the box with that image. You will then get a description right under the tab that tells you the name of the pattern and the size. For example, I selected one called Topographic Oceans:

GIMP Pattern selected
GIMP Pattern selected

When I click on it (highlighted in red in the image) I notice that the image is also shown on the tab itself up top. Right under that, it says Topographic Oceans, and gives the dimensions as 256 x 256. Knowing the dimensions of the image can be helpful if you want to use it to tile a background. To see how this would work, open a blank canvas, go to Bucket Fill, and in the tool options on the lower right make sure you have selected Pattern fill instead of Foreground (FG) color fill or Background (BG) color fill. Then just click on the blank canvas, and you will get something like this:

GIMP Topographic Oceans tiled
GIMP Topographic Oceans tiled

Bucket fill is something we looked at previously in Paint Tools. In this case we did a bucket fill of an entire rectangular image, which is what you might do for a background layer. But you can also bucket fill a selection, for instance. In this example, I created a blank canvas, then used the Text tool to write an upper case letter “A”. I made it red, then used the Select by Color tool to select the letter, and finally did a bucket fill:

GIMP letter filled with pattern
GIMP letter filled with pattern

This gave me a letter filled with the same pattern. And I could have used this technique to fill all the letters of a sentence if I wished, since the Select by Color tool will catch everything in a matching color.

You can also use the Clone tool with a pattern. Select the Clone tool (looks like a rubber stamp) on the left, and in the Tool Options at the bottom make sure you have selected as your Source the Pattern. I decided to use Cashews for this. Then, in the Tool Options for the Clone tool I bumped up the size to 15 pixels on my Brush (I had selected the brush “1. Pixel”), and then drew a freehand curve. This is the result:

GIMP freehand draw with Clone tool and Cashews pattern
GIMP freehand draw with Clone tool and Cashews pattern

Finally, we have the option of stroking along a path. Recall that we looked at Paths previously as one of our Miscellaneous Tools. The Paths tool lets you create Bézier Curves which you can manipulate using the tangent line “handles” into getting the shape you want. As we said then, the Bézier Curves themselves are vectors, so they can be resized without any loss of clarity. Stroking along a path means drawing a line, which can be solid, dashed, dots, etc. But if you are filling the line with a raster image, you cannot resize the stroked line without possible problems, so you should make sure you get the correct size before adding the pattern.

To do this, create a blank canvas, and make a path by clicking once to set an anchor point, then click a second time to add the second anchor point. A straight line will connect the two anchors. Then grab a point along that straight line and pull on it to get a curve you like. I then selected an abstract pattern called Chroma. Then go to the Edit menu and select Stroke Path. You will get a Dialog box like this:

GIMP Stroke Path dialog box
GIMP Stroke Path dialog box

Note that instead of Solid color, I have selected Pattern. But the default width here of 6 pixels is a bit small, so I will again increase it to 15 pixels. Click Stroke, and you are done. Here is my image:

GIMP Stroke Path with a Pattern (Chroma)
GIMP Stroke Path with a Pattern (Chroma)

Now, the patterns we have looked at come with GIMP, but you can always create your own as well. There are two places GIMP will look for Patterns: the GIMP system folder, which is where the built-in patterns are located, and the User folder. You should not mess with the system folder. If you want to add a pattern, it should go into the User folder. Just where this folder is located will depend on your operating system (GIMP is widely available on many operating systems), but for example on my system it is in the /home/user/.gimp-2.8 directory, along with folders for brushes, palettes, and so one. Remember that a pattern is nothing more than a rasterized image, so you can create one using GIMP itself. When you have it the way you want, you need to Export the file, and give it a *.pat extension. On my Linux box, I needed to export it to the Temp directory, then use the file manager to copy it into the Patterns directory. Once there, go back to the Patterns tab, and on the bottom click the Refresh, and your pattern will be added. You can then use it like any other pattern. If you no longer need it, you can click the Trash icon to delete it, but note that you cannot delete the built-in ones in the system folder.

So we have covered some of the uses of patterns.

Gradients

The other tab in the bottom right section is for Gradients, and it works much like the other tabs (Brushes and Patterns). If you view it as a List, it will look like this:

GIMP Gradients selector box
GIMP Gradients selector box

As with Brushes and Patterns, GIMP comes with a set of Gradients that are built-in, which you can use, and they are displayed in this selector box. You can apply a gradient using the Blend tool. When using this tool, what you need to do is draw a line that connects a starting anchor to an ending anchor, and that line is how the gradient will display. Here is an example using the Incandescent gradient and a horizontal line:

GIMP Gradient with a horizontal line
GIMP Gradient with a horizontal line

The same gradient using a vertical line:

GIMP Gradient with a vertical line
GIMP Gradient with a vertical line

And now one with a diagonal line from upper left corner to lower right corner:

GIMP Gradient with a diagonal line
GIMP Gradient with a diagonal line

That is fine for a background, but you can also use gradients with other tools, like Pencil, Paintbrush, and Airbrush. In each case the process is similar. You select the tool, and in Tool Options look for Dynamics. Click the button on the left, and select Color From Gradient. Then select the brush you want to use from the Brushes selector box on the right. Here is a free-form drawing I made with the same Incandescent gradient, the paintbrush tool, and the 2. Hardness 050 brush.

GIMP Gradient brush stroke
GIMP Gradient brush stroke

As with Patterns, we can apply a gradient to text by first using the text tool, giving the text a color, then selecting by color, and finally using the Blend tool draw a line across the text. In this example I drew a horizontal line for my gradient:

GIMP Gradient applied to text
GIMP Gradient applied to text

And finally, you can also use a gradient to stroke along a path. Simply create a path using the Paths tool, then select a drawing tool like the Paintbrush and make sure the Color From Gradient has been selected, as we did above. Then to the Edit menu, and select Stroke Path. Here is one I did:

GIMP Stroke with Gradient
GIMP Stroke with Gradient

I combined Patterns and Gradients in this tutorial because the tools are really very similar on use, so that the techniques you use with one work as well on the other.

Making your own Gradients

As with Patterns, you are not restricted to only using the gradients that came with GIMP. There is a user folder for ones that you create. And while you cannot modify the built-in gradients, you can copy them and edit the copies. Look at the bottom of the Gradient selector box, and you will see buttons to Edit, Create New, Copy, Delete, and Refresh. If you want modify a gradient, just copy it first, then edit the copy. When you do this, you will get the Gradient Editor on the top right:

GIMP Gradient Editor
GIMP Gradient Editor

By moving the triangles on the bottom you can modify the transition points between the colors in the gradient. Of course, in this case you are working with the existing color, but you can modify them as well. Just right-click on the gradient in the editor, and a pop-up menu appears:

Clicking on Left Endpoint’s Color or Right Endpoint’s Color will bring up the usual color palette dialog box where you can select a different color if you wish.

Creating a new Gradient is very similar to editing a copy. When you click the Create a new gradient button the Gradient Editor will give you a gray scale gradient to start with. Right-click on this to bring up the Pop-up box, and make your selections as usual.

Whether you created a new one or modified an existing one, saving is the same either way. Give it a name in the box on top of the Gradient Editor, then click the Save icon on the bottom left of the Editor. To see it in your Selector box on the bottom, click the Refresh button and it will appear. And if you no longer need it, you can use the delete button on the bottom of the selector. Just remember that you cannot delete the built-in gradients, just the ones you created.

Combining Tools

The other thing we did in this tutorial is combine tools. To make use of these techniques we combined the use of the Painting tools, the Path tool, the Color Select tool, Brushes, and used all of them with the Patterns and Gradients. And that is really how a application like GIMP is meant to be used. So while we started off slowly looking at specific tools in isolation, as we go forward we will be pulling tools left and right to achieve the results we want. Still, getting familiar with each of the tools individually is important in building confidence in using them.

Listen to the audio version of this post on Hacker Public Radio!

 Save as PDF