Lesson 13

Paths


Everything in the lessons so far has been in terms of pixels, because in general that's how the image data is stored. Now I will introduce a new kind of image data. In addition to pixels, it is also possible to store information in terms of "vectors." Vectors are sets of instructions that list individual points and describe the path to take to get from one point to the next.

To understand the difference between pixels and vectors, imagine that you are giving someone driving directions. Here are the two sets of directions:

  1. "Go straight for five blocks." This is pixel-like information. It will certainly do the trick, but the driver has to count every block, which takes up a lot of attention. If the destination happened to be ten blocks away instead of five, the driver would be likely to lose count along the way.
  2. "Go straight until you reach Main Street." This is vector-like information. You know the starting point, the ending point, and the path to take between the two. The driver just has to cruise along until reaching Main Street, so it doesn't take as much attention. Also, the same instructions work whether Main Street is five blocks away or ten blocks away.

Pixel data is stored as many tiny dots, and each dot has its own value. The computer must remember the location, color, intensity, and so on of every single pixel. For high resolution images, this can take up a lot of memory. In addition, changing the size of the image can affect its quality, expecially when enlarging. Vector data, in contrast, only requires the computer to remember a few points and a description of the paths connecting them. This takes much less memory. Plus, the advantage is that increasing or decreasing the size doesn't change the quality. (Many fonts are done with vector data because this allows them to appear the same at any size.).

Photoshop has two sets of tools for drawing vector paths and one set for manipulating them after they're drawn. Before you start using them, you should know a little about what these paths are and what you can do with them.

First, build on what you already know. Paths are similar to selection areas that you've been working with all along. In fact, you can switch between selection areas and paths quite easily. The difference is that paths can be manipulated after they are drawn, whereas with a selection area you are limited to painstakingly adding and subtracting to fix any mistakes in the shape.

Open a new image and make a random selection on it with the Marquee or Lasso. It should look something like the picture on the left. Next, right-click with the selection tool and choose "Make Work Path" from the pop-up menu and accept the default tolerance. The dashed marquee should turn into a solid line (right).

At the moment, it doesn't look any different from the original selection area. It does have new properties, though, and can allow you to do things that are impossible with a plain selection.

To demonstrate this, switch to the Brush tool and choose an attractive brush. I used a star. Next, use the Brush palette to set the jitter and other properties the way you like. I set my Color Dynamics to vary between yellow and orange, with 50% Spacing and 150% Scatter.

Once you have your Brush tool adjusted the way you want it, take a look at the Paths palette (left). The path you created should show up on this palette. Now, either click the icon at the bottom of the palette that looks like an empty circle, or right-click on the Work Path and select "Stroke Path" from the pop-up menu. If you do the latter, make sure that you specify the Brush tool when it asks.

The result should resemble the picture on the right. It takes the settings you selected with the Brush Palette and strokes the path, as if you had drawn along the path line with the Brush tool. This is a function unique to paths. What makes this function even more powerful is that you can stroke with the Eraser, the Blur tool, the History Brush, the Pattern Stamp, or any number of other tools in addition to the Brush.

You may wonder why this is any better than using the tools directly. Wouldn't drawing with the Brush tool give the same effect? Why go through all the trouble of making a path first?

The key is that, with a path, you can stroke shapes that would be difficult to draw by hand. For example, it is quite hard to draw a perfect circle. However, you can use the Elliptical Marquee to select a circle, convert it into a path, and then stroke that path. It looks just as if you had drawn the perfect circle yourself, with much less effort. Or you could type some text, Load Selection to select the outlines of the letters, and convert that selection into a path. This allows you to stroke in the shape of any font you desire.

If you aren't satisfied with the shape or position of the path, you can manipulate it directly. Choose the Path Selection tool from the toolbar (left). This tool allows you to select and move an entire path. Click on your path to select it.

You should see a number of small squares appear along the path (right). There are two different kinds of points that can make up a path. The first type serves as the ends of straight line segments. The second type, as in the current example, marks the center points of curves. With the Path Selection tool you can't affect these anchor points directly, you can only drag the entire path around. To work with the points that make up the path, switch to the Direct Selection tool instead.

If you click on a "smooth" anchor point with the Direct Selection tool, small rods with dots on the end will shoot out from both sides of the anchor point. These direction lines control the curve of the arc on either side of the anchor point. If you click all of the anchor points to make their direction lines appear, the path should look like the picture on the left.

Using the Direct Selection tool, you can click and drag the points themselves, or you can drag the direction lines to change the shapes of the curves. Unselected anchor points look white with a gray outline, while selected anchor points look like filled gray squares. You can manipulate each point individually, or you can select multiple points with Shift + click and manipulate them simultaneously. (Another way to select multiple points is by clicking and dragging to surround them.) Try experimenting with moving points around and altering the direction lines.

Right-clicking on a point makes a menu pop up that allows you to delete that point. Try deleting a point and see what happens. The line should change to connect the anchor points on either side smoothly. If you right-click on a section of the line where there is no anchor point, the pop-up menu allows you to create one there. You can also click and drag the curves directly. If you do so, the direction lines governing the curve will change automatically.

One of the options you can choose when you stroke a path is "simulate pen pressure." The result is shown in the picture (right). The two circles were drawn using the same path and the "Rough Dry Brush" tip. The one on the right was stroked with pen-pressure simulation on. This makes the brush stroke taper at the start and end points. You can adjust the amount that the stroke tapers with the "Minimum Size" setting in the Brush palette.

You can do other important things with the path besides stroke it. The first is that you can use Fill to fill it with a color or pattern, just as if it were a regular selection area. You can do so either by clicking the "Fill path with foreground color" icon at the bottom of the Paths palette or by right-clicking the path or the path layer in the Paths palette and choosing "Fill path" from the pop-up menu.

The second is that you can turn it into a "vector mask" for a new fill or adjustment layer, either through the Layer menu or the Layers palette. A vector mask is similar to a mask, except that you can't Alt + click and paint on it the way that you can with a regular mask. To alter a vector mask, you have to use the Path tool or the Pen tool.

If you wish, you can convert a vector mask into a regular mask by rasterizing it. "Rasterizing" is the process of converting vector data into pixel data. Once you have rasterized the vector mask, either by right-clicking on it in the Layers palette and choosing "Rasterize Vector Mask" or by clicking Layer → Rasterize → Vector Mask, the vector is converted into pixel data and can no longer be manipulated with the Path tool. The flip side is that it can now be altered with the Brush or the Eraser or any other regular tool.

A third thing you can do with a path is to convert it into a selection area. This selection area can be treated as any other selection area made with the normal selection tools. For example, it can be used to copy/paste or to make a layer mask.

In this example, you started by making a selection and converting it into a path. In addition to this method, you can also draw the path itself directly using the Pen tool (left). Choose the Pen tool and use the History palette to clear your image. With the Pen tool, click a few times around the blank image, but be careful not to drag. Wherever you click, the Pen tool leaves a "straight" line segment anchor point. Return to the beginning and click on the very first anchor point to close the path. Your image should wind up looking something like the picture on the right. What you have drawn is a path, as you can see if you check your Paths palette.

Undo your path and practice again. This time, click and drag. When you do, a line will stretch out between the anchor point where you clicked and the Pen tool tip where you drag. This line is the direction line for a curve. When you release the mouse button and click again, a curve rather than a straight line will form between the two anchor points. The more you click-and-drag, the more "smooth" anchor points you will make. Close the path by clicking on the first anchor point.

When you finish, the anchor points and direction lines should resemble the picture on the left.

You can combine smooth and straight anchor points in the same path (right). In this picture, the stars indicate clicks and the arrows indicate dragging. The top shape shows how you can sandwich curves between straight line segments by dragging instead of clicking. You can make both parabolic curves and sine curves. The bottom shape shows that you can make an anchor point with a straight segment on one side and a curve on the other by clicking to make the straight anchor point and then dragging on the same point to make a curve on the other side.

Drawing individual anchor points is one way to create a path, but it is also possible to draw the path as if using the Lasso to create a selection area. For this, choose the Freeform Pen tool. Draw the shape you want for the path. As you draw, the Freeform Pen tool will create anchor points automatically.

Take a look at the menu bar (left). The first three icons set what happens to the path when you finish drawing it. Number one automatically makes the path into a vector mask for a new fill layer and fills the new layer with the foreground color. This is the default setting for the Shape tool (to be discussed in Lesson 14). Number 2, the default for the Pen tool, simply draws a path without filling it or creating a new layer. Number three draws the path and automatically fills it with the foreground color, but does not make a new layer or a vector mask.

In the section under number four, you can use the icons to switch between the Pen tool, the Freeform Pen tool, and the various Shape tools. If you click the "Magnetic" option, marked number five, the Freeform Pen tool will act just like the Magnetic Lasso.

Section six lets you change the area that is included in the path. The first icon makes each path you draw additive. If you draw a single path with this, the area inside the path is selected (for Fill or for conversion into a vector mask) as in the picture on the left. The second icon will make each successive path subtract from the selected area. If you draw a single path with this, the area outside the path is selected (the inverse of the previous option) as in the picture on the right. With the third icon, only the junction between two paths is selected, and with the fourth icon, only the non-overlapping areas of two overlapping paths are selected.

Many professionals prefer using the Pen tool or the Freeform Pen tool to draw selection areas because the anchor points allow precise adjustment, resulting in more accurate selections and therefore better masks. When converting from a selection area to a path, you can adjust the number of anchor points that are created by altering the "tolerance" when prompted. A higher tolerance creates fewer anchor points. Fewer anchor points means smoother lines, because there are fewer separate segments (not to mention less data for the computer to juggle).

After you have drawn a path, not only can you add or delete anchor points, you can convert them between straight points and smooth points. This is accomplished by clicking on the point in question with the Convert Point tool.

Homework

  1. Use the Pen tool or Freeform Pen tool to draw a heart or other simple shape. If the shape isn't perfect the first time, use the Direct Selection tool to adjust the anchor points and direction lines. Stroke the path with a brush of your choice.
  2. Open an image and use the Freeform Pen tool to select an object in the image. Fine-tune the path if necessary. Convert the path into a vector mask for a new adjustment layer, and adjust one of the qualities of the object. Then rasterize the vector mask.