5.2. Создание анимированных кистей

Besides regular brushes that always use the same image, GIMP can also use animated brushes where each brush stamp is chosen from a range of choices available in the animated brush. GIMP calls these animated brushes «brush pipes» or sometimes image hoses, which is where the extension .gih is derived from.

Just like normal brushes, animated brushes can be grayscale or color. For grayscale images, where the actual brush uses the current foreground color, you use white for transparent areas and black for the image. For color images, transparent parts are used as such. When making brush strokes the actual colors will be used instead of the foreground color.

To create a new animated brush, create either a grayscale or color image, based on whether you want the brush to use the user's foreground color, or the actual colors in the image. Then create the images for your animation steps, called cells. You can choose to use one cell per layer, or divide each layer into multiple cells. To export the brush into gih format, select File → Export As…, name your work with the .gih extension, and press the Export button. The following dialog will be shown:

5.2.1. Export Image as Brush Pipe

Рисунок 7.18. Export as Brush Pipe Dialog

Export as Brush Pipe Dialog

Dialog to export an image as an animated brush


Этот диалог содержит несколько параметров, позволяющих выбрать, каким образом будет анимирована кисть.

Описание

The name of the brush that will be shown at the top of Brush Dialog in grid mode when the brush is selected.

Spacing (percent)

«Spacing» is the distance between consecutive brush marks when you make a brush stroke with your pointing device. Consider drawing with a brush or other paint tool as a form of stamping.

With a low value for Spacing stamps will be very close and look continuous. With a high value the stamps will be separated which can give interesting results with a color brush (like the «green pepper» brush for instance).

This is a value in the range from 1 to 1000. This percentage refers to the brush «diameter»: 100% equals the diameter of the brush and would mean that the brush stamps appear next to each other but don't overlap.

Cell Width, Cell Height

The width and height of a cell describe the dimensions of a single brush image or stamp. By default a cell has the same size as your image. Each layer should have the same size.

A cell can never be larger than your image, but you can make a cell smaller. You could for example divide the image width and height by two and then have four cells per layer. Of course you then need to design four different brush images on each quarter of each layer that you intend to use.

When more than one cell fits on a layer, one or more guides appear that show where the layer will be divided.

For instance, say we want a 100×100 pixels brush with 8 different stamps. We can create these 8 stamps by making 8 layers of 100×100 pixels. Alternatively we can make one layer of 400×200 pixels and set the cell dimensions to 100×100; or a layer of 300×300 pixels with the same cell dimensions but then one cell will be unused.

Число ячеек

The number of cells per layer. Each cell will be used as a separate brush stamp for the animation. Default (and maximum) is the amount of cells that fit in a layer based on the specified cell width and height.

Displays as

This label only appears if you have more than one cell per layer or when an error was detected. It shows how the cells will be divided for each layer. If, for example, you have placed height cells at the rate of two cells per layer, GIMP will display: Displays as a 1 × 2 grid on each layer.

Dimensions

The number of dimensions determines how many factors (see Ranks below) will affect which brush stamp will be used. Up to 4 different ranks can be used.

Порядки

«Ranks» are the factors that decide which brush stamp (cell) will be used when using an animated brush. The number entered here decides how many cells are available for this rank to choose from.

When exporting GIMP converts each cell to a separate brush image. When using the brush, GIMP considers each cell as a layer from the first cell at the top to the last cell at the bottom. You can see this in the Layers Dialog of the resulting .gih image file.

In our example we use 4 layers with 2 cells each. From top to bottom: first cell of first layer, second cell of first layer, first cell of second layer, second cell of second layer, …, second cell of fourth layer. Whether you decide to use one cell per layer or several cells per layer, the end result is the same.

GIMP creates an array from this stack of cells with the number of Dimensions you have set. You can use up to four dimensions, but in most cases one dimension is enough.

For two dimensions (2D), we talk about an array of rows (x axis) and columns (y axis).

When using three dimensions, often called 3D, we don't mention rows and columns, but use Dimensions and Ranks instead. The first dimension is along the x axis, the second dimension along the y axis, and the third along the z axis. Each dimension has ranks of cells.

To fill up this array, GIMP starts retrieving cells from the top. The way it selects cells is similar to that of an odometer: the rightmost rank digits change first. When they reach their maximum, the digits of the rank to the left start increasing.

For example, with an array(4,2,2), i.e. 4 choices for the first dimension, 2 choices each for the second and third, you get the following succession: (1,1,1), (1,1,2), (1,2,1), (1,2,2), (2,1,1), (2,1,2), (2,2,2), (3,1,1), …, (4,2,2). We will see this later in an example.

Выбор из списка

For each rank, you can set how a cell is chosen from the amount of cells set in Ranks. The following Selection modes are the options that determine how the next brush image will be chosen:

Постепенный

GIMP selects the next cell within this rank for the current dimension, and at the last continues with the first.

Угловой

GIMP selects a rank in the current dimension based on the current angle of the brush.

The first rank or direction is to the left. The actual angle depends on the amount of ranks; for 4 ranks you get an angle every 90°, so we start at -90° (270°), i.e to the left. The next ranks are selected counterclockwise depending on the angle and the amount chosen in ranks, which computes to 360 divided by the number of ranks.

So, with 4 ranks in the dimension, the angle will move 90° counterclockwise for each direction change: the second rank will be 180° (downwards), the third rank 90° (to the right) and the fourth rank will be at 0°.

[Примечание] Примечание

Be aware that when dynamics is enabled the brush shape is turned 180° relative to when it is disabled. If you need the same angle, you can adjust the Angle by 180° in the Paint Tool Options.

Случайный

GIMP selects a rank at random from the cells available for that dimension.

Скорость, Нажим, Наклон по X, Наклон по Y

The cell to draw is selected based on one of the characteristics of your drawing device. Only works when your device supports this.

5.2.2. Animated Brush Examples

Примеры

A one dimensional animated brush

Most animated brushes use one dimension. This means there is only one characteristic that decides which brush cell will be used next.

A 1D brush can be visualized like this:

To create a brush like this, follow these steps:

  1. Выберите пункт главного меню Файл → Создать….

    Установите для Ширины и Высоты, например, 30 пикселей.

    В Расширенных параметрахустановите для Цветового пространства значение Цвет RGB, а для Заливки — Прозрачность.

    Using the Text tool create 4 layers «1», «2», «3», «4». Delete the «Background» layer.

  2. Выберите Файл → Сохранить… из главного меню, чтобы сначала сохранить изображение как файл .xcf для сохранения его свойств.

    Выберите Файл → Экспортировать как… из главного меню, чтобы экспортировать изображение как анимированную кисть с расширением .gih.

    Browse to the location of the brushes directory located inside your personal GIMP configuration folder. This location can be found by going to the Brushes folder in Preferences and then click the file chooser button on the right.

  3. In the Export Image as Brush Pipe dialog, provide a Description, set the Spacing (percent) to 100, set the Cell size to 30×30, set Dimension to 1, set Ranks to 4, and in the Selection drop-down select Incremental. Then click the Export button.

  4. In the Brush Dialog, click the Refresh brushes button.

    Your brush appears among the other brushes, sorted alphabetically. You can use it immediately, without restarting GIMP.

    Select your brush. Select a Paint tool, the Pencil tool for instance and use it to draw on a new image:

    You see the digits 1, 2, 3, 4 appear in incremental order.

  5. Reopen your .xcf brush image file and export it again as .gih. This time set the Selection drop-down to Random:

    When using the brush the digits are now displayed in random order.

  6. Now change the Selection drop-down to Angular and export again. The result is shown below:

A three dimensional animated brush

We are now going to create a 3D animated brush: its orientation will vary according to the brush direction, it will alternate Left/Right hands regularly and its color will vary at random between black and blue.

The first question we have to answer is the number of brush cells that we need to create. We will use the first dimension (x) for the brush direction (4 directions). The second dimension (y) is for choosing between Left and Right (2 cells), and the third dimension (z) is for selecting the color (2 cells).

A 3D brush like that can be represented visually as follows:

There are 4 ranks in the first dimension (x), 2 ranks in the second dimension (y) and 2 ranks in the third dimension (z). Thus we need 4×2×2 = 16 image cells.

  1. Create images for dimension 1 (x)

    Откройте новое изображение размером 30x30 пикселей, RGB с прозрачным типом заливки. Нарисуйте левую руку с пальцами вверх. [2] Используйте масштаб для точного рисования. Сохраните изображение как handL0k.xcf (левая рука, 0° поворота, чёрная).

    Откройте диалог слоёв. Нажмите дважды на слой, чтобы получить диалог свойств слоя и переименуйте его в handL0k.

    Duplicate the layer. Leave only the duplicated layer visible. Select it and apply Layer → Transform → Rotate 90° clockwise. Rename it to handL90k.xcf.

    Repeat the same operations to create handL180k.xcf and handL-90k.xcf (or handL270k.xcf).

  2. Create images for dimension 2 (y)

    This dimension in our example has two ranks, one for the left hand and the other for the right hand. The left hand already exists. We create the right hand images by flipping the left hand horizontally.

    Duplicate the «handL0k» layer. Make that the only visible layer and select it. Rename it to handR0K.xcf. Apply Layer → Transform → Flip Horizontally.

    Повторите ту же операцию над другими слоями слева, чтобы создать им правосторонний эквивалент.

    Reorder the layers to have a counterclockwise rotation from top to bottom, alternating Left and Right: handL-90k, handR-90k, handL180k, handR180k, …, handR0k.

  3. Create images for dimension 3 (z)

    The third dimension has two ranks, one for black and the other blue hands. The first rank, black, already exists. All image cells of dimension three will be a copy, in blue, of the images of dimension two. This requires a total of 16 images. However, a row of 16 layers can be cumbersome to manage. Therefore we will use layers with two image cells.

    Select the «handL0k» layer and make it the only one visible. Use Image → Canvas Size… to change the canvas size to 60×30 pixels.

    Duplicate the «handL0k» layer. On the copy, fill the hand with blue using the Bucket Fill tool.

    Now, select the Move tool. Check its Tool Options and set Tool Toggle (Shift) to Move the selected layers. Move the blue hand into the right part of the layer and align its edges with the corners of the image canvas. You can use Zoom or the arrow keys to make it easier to align it exactly where needed.

    Make sure only «handL0k» and its blue copy are visible. Right click on the Layers dialog, then apply the Merge Visible Layers command with the option Expanded as necessary selected. The result is a 60×30 pixels layer with the black hand on the left and the blue hand on the right. Rename the layer to «handsL0».

    Повторите эту операцию над другими слоями.

  4. Arrange layers in the correct order

    The layers must be arranged in the correct order for GIMP to find the required image when using the brush. Our layers are already ordered the right way, but let's take a look at ordering to better understand how to do that manually.

    There are two ways to think about this. The first method is mathematical: GIMP divides the 16 layers first by 4; that gives 4 groups of 4 layers for the first dimension. Each group represents a direction of the brush. Then, it divides each group by 2; that gives 8 groups of 2 layers for the second dimension: each group represents a left or right choice. Then another division by 2 for the third dimension to represent a color at random between black and blue.

    The other method is visual, by using an array representation. The relationship between the two methods is shown below:

    Слой Cell Array # Choice   Figure
          X Y Z    
    HandsL-90 HandL-90k 1,1,1 1      

    X: Brush direction; angular selection (first rank).
    Y: Left/Right hand; incremental selection (second rank).
    Z: Color; random selection (third rank).

    HandL-90bk 1,1,2 2    
    HandsR-90 HandR-90k 1,2,1 3    
    HandR-90bk 1,2,2 4    
    HandsL180 HandL180k 2,1,1 5 5  
    HandL180bk 2,1,2 6 6 6
    HandsR180 HandR180k 2,2,1 7    
    HandR180bk 2,2,2 8    
    HandsL90 HandL90k 3,1,1 9    
    HandL90bk 3,1,2 10    
    HandsR90 HandR90k 3,2,1 11    
    HandR90bk 3,2,2 12    
    HandsL0 HandL0k 4,1,1 13    
    HandL0bk 4,1,2 14    
    HandsR0 HandR0k 4,2,1 15    
    HandR0bk 4,2,2 16    

    How does GIMP read this array?

    GIMP starts with the first dimension which we set to «Angular», for instance 180° (X: choices 5, 6, 7, 8 shown in yellow). In the second dimension, it selects a Left or Right hand, in an «incremental» way (Y: in this case a left hand, choices 5 or 6). Then, in the third dimension, it chooses from black or blue randomly (Z: random choice blue is 6). For this to work our layers must be in the order as shown in the table above.

  5. Now your animated brush is ready. Save it as .xcf first, then export as .gih with the following parameters:

    • Расстояние: 100

    • Описание: Руки

    • Размер ячейки: 30x30

    • Чисто ячеек: 16

    • Измерения: 3

      • Dimension 1: 4 ranks; Selection: Angular

      • Dimension 2: 2 ranks; Selection: Incremental

      • Dimension 3: 2 ranks; Selection: Random

    Place your .gih file in GIMP's brush directory and refresh the brushes in the Brush dialog. You can now use your brush.

    Рисунок 7.19. Вот результат штрихования кистью эллиптического выделения:

    Вот результат штрихования кистью эллиптического выделения:

    This brush alternates right hand and left hand, uses black and blue color at random, and the direction the hand is pointing depends on the direction the brush is going.




[2] Мы позаимствовали изображение руки у https://commons.wikimedia.org/wiki/File:Stop_hand.png.