Sunday, June 15, 2008

GIMP Path Tool (aka Pentool) Tutorial

In this tutorial, you will learn the Path Tool (aka Pentool) in GIMP. The Path Tool is used to create complex shapes and curves. Many people don't use it since it's too complicated, However today I'm going to show you that it's not.
Note: This tutorial was transfered from my old website, and it's now updated with more information

Before we start, we need to define several stuff:
  • PathTool (aka PenTool) - A tool use to create paths.
  • Point (aka Anchor) - self explanatory :D
  • Line (aka Segment) - a connection between 2 points (not more and not less then 2)
  • Control (aka Handle) - a special kind of point that controls the curve of a Line. From each point you have 2 controls - one for the line that ends at the point and one for the line that starts at the point.
  • Stroke - one or more Points (Anchors) which are conected to each other. A closed stroke is a stroke where the first and last points are connected, and an Open Stroke is a stroke where the first and last points are not connected.
  • Path - a path is a collection of one or more strokes

An illustration showing the different parts of a path.

There are 3 strokes in this illustration:
(1) a classical curved stroke, (2) A polygonal stroke and (3) an open curved stroke

PathTool Tutorial - Basics

The tool options tab showing the options
for the path tool

Here is a basic demonstartion of using the Pentool/PathTool:

An illustration showing how a segment between two
points bends, depending on the positions of it's handles

Now we need to explain 2 more things:
  • An Active Point is the last point (anchor) that you clicked on. A point can also become active if you drag a line that it's connected to (see explanations in the illustration below)
  • A control (handle) becomes visible only if the point it's part of is active.
In order to curve the line, while in "design" mode click on a line and drag it, notice that handles will come out of the points - these are used to control the curve of the line. If you click on the handle and drag it you will be able to control the curve of the line more accurately.
By controling the handles you can have up to 2 curves per line so if you want more you will need more dots.
In the animation above I clicked on the line and dragged, once next to each point.

Excercise - Drawing a tip of a brush
Now let's try to be more practical: let's create something!

An illustration showing what
you should do

Create the first two points by clicking on the canvas (while using the path tool in design mode) and then bend the line between them as showed above (by clicking on it and dragging). To curve the path like this I first clicked next to the bottom point and dragged to the right and then clicked next to the top point and dragged to the left.

Now create the third point by cliking the canvas in the position showed above.

What happened?! why didn't the new point Connect to the old one?

The answer is simple: GIMP connects the new point only when the active point before you created the new one, was at the end of the path (when a point is selected and becomes active it will look empty and a frame will appear in the place you should have a filled circle). When dragging the segment between two points, both of them become active and so GIMP doesn't know which point to connect to the new point.

In order to reconect this point, make sure it's active (if not, click on it), now Ctrl+Click on one of the dots at the end to connect it. Most of the times you won't need to do manual connections since the points will be connected automatically. This only happens if you have more then one active point or when the active point is not at the end of a path.

Later on in this tutorial, we'll see how to bend line segments without going through this trouble.

We will now delete the newly created point (it was created for education purpose only, to show you the above bug and how to connect points) by clicking the backspace or delete buttons on the keyboard. Now connect our second dot to the first one.
Now bend the new line segment as shown below (drag the line first to make the handles emerge, and the fine tune the curve by moving the handles)

Finishing the tip of the brush

Final Result
Path-Tool Tutorial - Detailed Explanation

The cursor icons for different path operations, Updated for GIMP 2.6

Shortcut Keys:
  • Design - Deafult
  • Edit - Ctrl
  • Move (Stroke) - Alt
Anchor Actions:
  • Deleting - Holding Shift on Edit (Ctrl) mode and clicking on it. See the comment at the end of the tutorial about straighting curved strokes.
  • Moving - Clicking on it and dragging in Design mode.
  • Adding at end - Design mode, active point should be open at one side
  • Adding at the middle of segment - Clicking on a segment in Edit (Ctrl) mode
Line (Segment) Actions:
  • Deleting - Holding Shift on Edit (Ctrl) mode and clicking on it
  • Moving - Clicking on it in and dragging in Design mode
  • Connecting - Clicking on a point in Edit (Ctrl) mode while both active point and the point you are clicking on are unconnected at 1 or 2 sides
Control Actions:
  • Deleting - Holding Shift on Edit (Ctrl) mode and clicking on it
  • Moving (When Visible) - Clicking on it in and dragging in Design mode
  • Moving (When Invisible) - Clicking on it's Point (Anchor) and dragging in Edit (Ctrl) mode
Stroke Actions:
  • New - Clicking anywhere in design mode when the active point is connected on both sides or when there is more then one active point or Clicking Shift while in Design mode and then clicking anywhere you want.
  • Move - Clicking on a stroke and then dragging while in Move (Alt) mode.
Note: The "Move Stroke" cursor is also used when using the move tool on "Path". Don't get confused - when moving with the move tool the entire path wil be moved - not just the specific stroke

PathTool Tutorial - Selections and Stroking

Selection - a selection from a path is basically the area inside the path. When the path is Open, it's treated like there is a straight line from the starting point to the end point.

When we have an area covered by 2 paths (or any other even number) it won't be selected. Imagine a ring in real life, the edges of the ring are 2 circles when one is inside another and the area covered by both rings is the hole.

When we have an area covered by 1, 3 (or any other odd number) it will be selected. When we have an area covered only by one path it will be selected since this is how we defined the selection. When an area is covered by 2 (or any other even number) paths it will be a hole so when we have 3 (or any other odd number) it will be full again since we have 1 path inside a hole (the 2 paths cancel each other so we we have nothing in this area except for the one path and then this is the selection)

An illustration showing the selection created by different paths

Stroking - stroking a path (to stroke a path) means to draw along it's lines. In order to do this simply click on the path you want to stroke inside the paths dialog (To open it, go in the menu to Windows→Dockable Dialogs→Paths) to make it the active path, and then go to the Edit→Stroke Path...

In the dialog that will pop you can select how to stroke the path, which tool to use it and you can set many other options - try playing with it.

An Illustration showing some example of what can be achieved by different configurations for stroking the path

Important Tips/Tricks for easier usage
Drawing Curved Paths
It's very annoying to have to draw a polygonal path and only then to curve it. In fact, you can draw a curved path right away! This requires a bit of practice but this is how it works:
When you create a new point in design mode, instead of clicking and releasing the mouse right away, click and drag. The handle will move to where you drag your mouse and this way you can create curved paths directly when drawing them!

Smoothing Points
A path looks smooth when it passes through a point, if both of it's handles look as if they are on one straight line.

An illustration showing when a path is smooth

Note that the two handles don't have to be symmetrical (when the point is the center of the symmetry) in order for the point to look smooth.
In order to make both handles symmetrical, while dragging one handle hold the Shift button and the other handle will become symmetrical!

Straightening line segments
If you want to draw a polygonal stroke, you can simply toggle the checkbox labled "Polygonal" in the tool options tab (see screenshot above). But, if you want to straighten one line in a curved stroke it's a bit harder.
A staright line segment is produced when the handle coming out from each of it's points, is exactly as the same location as the point - to achieve this one can simply "Delete" the handles (see keyboard shortcut above) of the two points of this line segment.

18 comments:

  1. thks for such a detailed explanation-- I find most explanations of complex functions assume we are intuitive, and they don't explain the context of the operation fully which results in a lot of frustration trying to learn by 'playing'. Am very appreciative of this tut.

    ReplyDelete
  2. Thank you very much.
    Perfect tutorial.

    ReplyDelete
  3. [...] LightningIsMyName at LightningIsMyName’s Website presents us with an extensive guide to any and all things path tool. Link. [...]

    ReplyDelete
  4. [...] LightningIsMyName at LightningIsMyName’s Website presents us with an extensive guide to any and all things path tool. Link. [...]

    ReplyDelete
  5. Next time include sources please =)

    ReplyDelete
  6. ditto what elaine above wrote. now I'm off to create things.

    ReplyDelete
  7. Tyvm I couldn't work out what keys to hold down. It be even better if photobucket reactivates your pictures ;)

    ReplyDelete
  8. Thanks - been searching for days for a clear explanation. Not event the gimp help website explained the use of the gimp tool as well as this. Cheers mate have a bevvie on me!

    ReplyDelete
  9. This really helped me cope. IN YOUR FACE PHOTOSHOP!

    ReplyDelete
  10. Thanks...gonna try it out. But my question is... is it possible to use this tool to curve straight angles in a pre-existing image, such as a photo? If not with this tool, are you aware of any other means by which this can be accomplished? I cant find information anywhere on this subject. I had an image which was a trapezoid and wanted to alter it significantly, easily. Thanks for your help.

    ReplyDelete
  11. @black_beauty2u:
    The paths tool is only meant for drawing and creating new shapes. In order to curve existing lines inside image, try the following tools:
    1. The IWarp filter (Filters->Distort->IWarp). Should be very intuitive to use, but if not google it :)
    2. Possibly (although not likely) you can try the Curve and Bend filter (Filters->Distort->Curve and Bend)

    And probably the best way to do this is using the new Cage tool - it's less than one week old so you won't find it in any of the recent official builds - you'll need to compile gimp from source yourself (easy if you are using linux). You can see a cool preview of it here: http://www.youtube.com/watch?v=YLt3Uo5cMbA and here: http://pellelatarte.fr/en/

    ReplyDelete
  12. Lot of work on this tutorial, thanks for your efforts. really well done.

    ReplyDelete
  13. Thank you so much! I'm gonna try it all.

    ReplyDelete
  14. Awesome! Thanks for this. It's easy to forget the importance of fundamentals at times.

    ReplyDelete
  15. thanks for the tutorial....
    but what a horrible sense of "intuitive" gimp developers have....

    ReplyDelete