Computer Graphics

Basics: Layers

In order to have the best options to work with graphics information, several ways of separating the different elements of the image have been developed. Among them are: selection, layers and masks. We'll start with layers.

1. Create new file

Click on File > New ... and enter the size for the new image file. This is up to you, I chose 640 x 480 pixels. Your window will now contain a blank white image:

2. Draw a simple picture

As you can see in the Layers panel, there is currently only 1 layer in the image and it's called Background. This is the default behavior after creating a new image or opening an image file that has no layers (e.g. JPEG or PNG).

Select the Paintbrush tool (P) in the Tools panel, pick a nice green color for the foreground color and draw a nice green lawn in the image. Then change the color to blue and draw the sky. Finish your image by drawing a white cloud. If necessary, change the brush size in the tool options panel in bottom left.

This is what you should have by now:

3. So... when does the layer thing start?

Right now. Image somebody told you to move the cloud a little bit in this image. What would you do? Or imagine somebody told you to draw a yellow sun behind the cloud. There is no convenient way to that at this moment, because all three things: grass, sky and cloud were drawn in the same layer called Background. The next things we draw will therefore occupy separate layers.

Let's create a new layer. There are several ways to do that:

  • In the main menu Layer > New layer ...
  • Clicking on the new layer button in the bottom left of the Layers panel
  • Using the hotkey Shift + Ctrl + N

Whichever way you choose, a dialog will open asking you to specify the parameters of the new layer. For the moment, just specify the name of the new layer: Sun.

You can now see that there are two layers in the Layers panel. One is called Background and the other is Sun. We will be drawing now in the Sun layer, so make sure click the Sun layer in the Layers panel so that GIMP knows which layer is the active one.

Next, pick the Paintbrush again and select yellow color. Choose a brush that is round and sharp. Different brushes can be selected either in the Brush palette in the bottom right corner of the application or in the tool options panel, right below the Opacity bar. Increase the brush size to, say, 100 pixels in the Tool options and click once somewhere in the picture to draw a nice round and yellow sun:

4. Why we needed a layer to do that?

Remember when I asked you how would you move the cloud? And there was no easy way to do that? We can now move the sun very easily. Just select the Sun layer and pick the Move tool (M) from the Tools panel. It looks like a blue cross with arrowheads. With the Move tool selected, click and drag the sun around to see it's completely independent from the Background layer.

Note: Sometimes a different layer might move rather than the one you wish. That's because you might have missed the layer's area in the picture and accidentaly selected a different layer to be moved. To prevent this, set the Tool options for the Move tool Move the active layer. This way only the layer that's active in the Layers panel will move and none other.

5. Practice on your own

Repeat step 3. But now create a new layer called Cloud and paint a gray cloud in the layer. Like this:

6. Layer order and opacity

Now that we have multiple layers in our image: Background, Sun and Cloud, we can see what else are layers good for. We've already tried moving Sun around by the Move tool. But we can also move the sun to be in front of the cloud. (Not realistic, I know). Select the Sun layer in the Layers panel and drag it above the Cloud layer. See? The sun is no longer occluded by the cloud. To bring the sun back behind the cloud where it belongs, either drag the Sun layer back below the Cloud layer or drag the Cloud layer above the Sun layer.

Also, each layer has its own Opacity, which determines how much is the layer opaque (i.e. visible) or if it's transparent. The Opacity bar is in the Layers panel. Make sure the Cloud is above the Sun layer and change the Cloud layer's opacity to 75%. See what you did there?

There is more to layers than this, but we'll get to the rest in due time.