Have you ever found yourself wondering, “How do I apply a gradient to a stroke?” or, perhaps, “How do I make a gradient follow a curve?” Unfortunately, there isn’t a simple solution in Illustrator for these questions. However, there are some ways to achieve the appearance of having a gradient follow the curves of a path. In this example, we will be looking at how to apply a gradient to a path as a brush stroke, by creating an Art Brush based on a gradient. This is intended for intermediate Illustrator users and assumes the user has a basic working knowledge of Illustrator tools.

Tools/Functions Used:

  • Rectangle Tool
  • Gradient Palette
  • Expand Function
  • Transform Palette
  • Brushes Palette
  • Brush Tool and/or Pen Tool

When asking “How do I apply a gradient as a stroke?” you’ll often be told that the solution is as simple as expanding your stroke into a shape (select your path, and use either Object>Expand or Path>Outline Stroke) and then applying your gradient. This is all fine and dandy, unless you expect that your gradient is going to following the curvature of your original stroked path.

Outlined stroke filled with a gradient vs. stroke with gradient brush applied

Outlined stroke filled with a gradient vs. stroke with gradient brush applied



As you can see in the image above, applying a gradient to an expanded stroke will not make the gradient itself follow the along the path of the stroke. However, applying a gradient brush to a path yields very different results. So, how do we create a gradient brush? It’s actually fairly simple.

Our first step is to use the rectangle tool to create a square (hold Shift when using the rectangle tool to constrain the proportions to a square). This square is going to be the “template” for our brush, so the final size of the square is important. In this example, the final size of my square is going to be 10px X 10px. I’ll explain why the size of the square is important in a little bit. For now, I will use a larger square, so that you can see what’s going on.

Use the rectangle tool to draw a square

Use the rectangle tool to draw a square

With our rectangle drawn, we will now select a gradient that we want to create a gradient brush with. For this example, I will be using the Spectrum gradient from the Spectrums Swatch Library (in Illustrator CS4, from the Swatch Palette, Open Swatch Library>Gradients>Spectrum).

Spectrum gradient

Spectrum gradient

You can use this method for any gradient you wish, the steps are the same regardless of your gradient. Once you have chosen a gradient to use, select your square, and:

  1. Set the Fill on the square to your desired gradient
  2. Set the Stroke on the square to Transparent (No Stroke)
Gradient fill with no stroke

Gradient fill with no stroke

At this point, we want to have our Brushes Palette open, if it is not already open go to View>Brushes (F5 keyboard short cut).

Brush Palette

Brush Palette

To create our gradient brush, we are going to select our square and drag it over into the brush palette and specify it as a new Art Brush. However, there are a few steps we have to take before we can do this. If we were to attempt to drag the square into the palette at this point, Illustrator would give us the option to specify our brush as a new Art Brush, but we would then receive the following message.

Gradients cannot be used in an Art Brush!

Gradients cannot be used in an Art Brush!

We cannot convert our square to an Art Brush because it contains a gradient. Fortunately, we can get around this problem and still maintain the appearance of our gradient, by expanding our gradient into individual shapes. To do this, select your square, and from the main menu select Object>Expand to bring up the Expand dialog box. In the Expand dialog box, you need to make sure that “Expand Gradient To” option is set to “Specify: 255 Objects.” The default for the number of objects to expand your gradient to should be 255. What this number specifies is the number of objects/shapes used to create the appearance of our gradient after it has been expanded into a series of objects. The higher you set this number the closer your expanded gradient will appear to its original gradient appearance. However, setting this number too high can cause some serious performance issues, so if you’re going to experiment with altering this value, try to use the lowest number of objects necessary to achieve your desired gradient appearance. (Note, if you select “Expand Gradient To Gradient Mesh” you will get the error message above when trying to create a new Art Brush.)

Expand Dialog Box - Set Expand Gradient To Specify 255 Objects

Expand Dialog Box - Set Expand Gradient To Specify 255 Objects

Now that our gradient has been expanded, we need to make sure that we don’t have any other elements that would prevent our gradient square from being converted to an Art Brush. When we expanded our gradient, Illustrator created a Clipping Mask around our object. We need to remove this before we can create our Art Brush. With our gradient square still selected, from the main menu select Object>Clipping Mask>Release (Ctrl-Alt-7 keyboard short cut).

Release the clipping mask

Release the clipping mask

Once the clipping mask is released, it might appear as if your square has changed to a solid fill color, as seen in the image below.

Square after clipping mask is released

Square after clipping mask is released

Fear not, what you’re seeing the selection highlights of all of the shapes that our expanded gradient are made up of. There are so many of them that when the square is selected, the highlight color for the layer that our square is on, appears as a solid color. If you deselect the object, you will see that all of our gradient elements are still there just as they were before we released the clipping mask.

Earlier, I said the size of our square was going to come into play. The reason that the size of the square is important is that the size of the square when we drag it into the brush palette will determine the size of our brush when set at 1pt. When we set up are Art Brush, we can specify the width as a percentage of our original square, but to save us from calculating a percentage width (in the event that you have some arbitrary values for height and width), we will go ahead and set our square to the width that we want our brush to be at 1pt. To do this, we select our square and set the height and width to 10px using the Transform Palette, Widow>Transform (Shift-F8 keyboard short cut).

Set the Width and Height to 10px with the Transform Palette

Set the Width and Height to 10px with the Transform Palette

Now, we’re finally ready to drag our square to the Brushes Palette. Click on the square and hold the mouse-button down and drag it over to your Brushes Palette. When you see a “+” symbol next to your mouse pointer you can release the mouse button (see below).

Drag the "gradient square" to the Brushes Palette

Drag the "gradient square" to the Brushes Palette

When you release the mouse button, the New Brush dialog box will appear. Select “New Art Brush” from the options and click “OK.”

Select New Art Brush

New Brush dialog box

The Art Brush Options dialog box will automatically pop-up after you click “OK” on the New Brush dialog box. We can name our brush here. I’ve chosen to name my brush “Spectrum Brush” for this example. You’ll notice an option for “Width,” as well. We can leave this at 100%, since we already set our brush width to 10px when we used the Transform Palette. Leave the “Proportional” option unchecked. What it does is essentially sets the width of your brush stroke equal to the length of your stroke, and this isn’t really what we’re after with this particular brush. For the “Direction” option, select the icon that looks like an “up arrow.” This is the “Stroke from bottom to top” option (see image below for examples of each Direction option). We will leave the flip and colorization options at the default settings (none) for this brush.

Art Brush Options dialog box

Art Brush Options dialog box

Art Brush Direction examples

Art Brush Direction examples

Once you’ve got your options selected in the Art Brush Options dialog box, click “OK,” and your new “gradient brush” will appear in the Brushes Palette! You can delete the gradient square that we used to create our brush at this point. The put your new brush into action, click on it in the Brushes Palette if it is not already selected and then select the Brush Tool or Pen Tool to try it out! You can also apply this brush to shapes created with the Shape Tools by selecting a shape and then click on the brush in the Brushes Palette. It probably won’t take you long to notice some oddities in these kinds of brushes. Sharp corners and tight curves tend not to work so well with a “gradient brush.”

When and when not to use this kind of brush

When and when not to use this kind of brush

Keep in mind, since these brushes are comprised of expanded gradients, excessive use of them in a document will likely bog down Illustrator. Remember, we used 255 objects to create the appearance of the spectrum gradient, so there is “a lot going on” when we use this brush, as compared to more simple brushes. Have fun with them, but don’t overuse them to the point that Illustrator decides to takes a long nap on you, when you’re in the middle of a project that you haven’t saved for a while.

Tags: , , , , , , , , , , , , ,
3 Responses to “Applying a gradient to a path – Gradient Brush”
  1. Thanks for this tutorial, I was looking for an answer for long time. Much appreciated!

  2. Asiaed says:

    What would cause the “stroke” in “expand” be grayed out and unselected. cause i can’t get it to work
    Thank you
    Asia

  3. George says:

    Asia,

    If the stroke is grayed out, it’s likely due to not having a stroke applied to the box with the gradient, which is fine. The fill (in this case the gradient) is really the only thing that you need to expand.

  4.  
Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>