Make a gradient following a Path

dmoring
dmoring used Ask the Experts™
on
I want to make a gradient but not simply linear or radial but rather the gradient following a path.  I've read and experimented without luck.  Can someone describe to me a good process for this?  I've attached one example as the gradient/fade on a line I want to achieve.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Have you tried creating a linear gradient and then warping that image?

Author

Commented:
I've tried it with a basic Polar, but the one I need at the moment is a wave - not a semi-circle; is there a way to warp it along a path?  If so, how?  I forgot to upload a similiar graphic sample of it...  Here it is...
Line-GradientExample.jpg
You could recreate that image by putting that wave on its own layer and then adding a "Inner Shadow" effect.
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

Author

Commented:
This is just a sample, but I'm trying to achieve the same affect.  I've tried something like that with an inner shadow of the path doesn't seem to extend very far or I can't figure out how to make it go further....
Have you tried using the gradient mesh tool?

If that doesn't work here are a few other options:
http://creativemac.digitalmedianet.com/articles/viewarticle.jsp?id=30831


Here is a different approach, it seems the best way. I haven't used this one, but it looks very useful:
http://www.gtpdesigns.com/blog/illustrator/applying-a-gradient-to-a-path-gradient-brush/

Author

Commented:
Hah - what on earth is a gradient mesh tool?  I will have to look at this!  I will advise...

Author

Commented:
Actually, these are all pretty neat but for Illustrator - not PS.. at least as far and I can find!. ;-(
Sorry, I don't know why I was thinking Illustrator. I will look at Photoshop for a solution.

Author

Commented:
Thanks so much - I saw earlier today the options were there in Illustrator, but it seems like the functionality should be there in Photoshop too!
Yes it is, it will take a little more work though. I will try a few and make a short tutorial about it.
One option is to use the Pen Tool and fill the path with a gradient, this will allow you to change the path and the gradient will flow to fill it.

Choose Pen Tool from the tool bar.
Click 'Shape Layer' from the Options Bar along the top.

Draw your path using the pen tool. The layer will be filled with the foreground colour but don't worry about which colour it is.
A new layer is created with the foreground colour and a path shape. Right-click on the layer in the Layers Palette and choose 'Blending Options'.

Under Blending Options choose 'Gradient Overlay'. Set your gradient options and click OK.
You can now move the points of the path around and the gradient will only fill the path. You can also add and remove points as with any vector shape.
gradient-path.png

Author

Commented:
@IBM, I need the gradient levels to follow the path - that's the issue; NOT making a custom shape with a gradient!  
Sorry, my mistake. You can't make a raster image track a vector path, you can only warp the rastered image after creating it.
The Warp or Liquify tool are the only real options but they will distort the flow of colour along the gradient which I'm assuming you already know.

These articles might get you a step closer to the effect you're after though:
http://forums.cgsociety.org/showthread.php?f=14&t=738415

Corey Barker has a video tutorial called 3D Tubes which might be useful as well but you need to be a NAPP member to view it:
http://www.photoshopuser.com/?aid=mzfahr

Another alternative is try some stand alone products to create the gradient image then import it into Photoshop.
I'll keep an out for alternatives though.

Author

Commented:
My first question to that would be theoretical: would be why does the gradient have to be a raster image and not a vector?  I have not tried the warp, but will do so... also hoping jeremyjared74's "tutorial" has the long-lost answer!
I figured it out. It I will post after work

Author

Commented:
@jeremy, Thanks!

@IBM, the warp *can* work, but its a real pain to experiment with the angles numerically when its easier to move/visualize with UI movements... But thanks for the idea and will keep it in mind if I can't find another way!
OK, Finally. I did it last night and I couldn't recreate it. Here is how I did it:
  1. Create a complete path in Photoshop using the pen tool I made everything but the curve go outside of the artboard, so only  the curve shows
  2. Go to paths in the layers palette and select stroke path from the drop down meny
  3. Now go to the Masks tool palette and choose gradient map to create a gradient map
  4. Make sure you have the layer that has the gradient map selected (you also need to click on the shape inside of the gradient map inside the layer to select the path)
  5. Go to fx in the bottom of the layers palette and choose stroke
  6. In the stroke options select Gradient in the fill type (the default is color.
  7. Now choose a gradient or create one.
This should work. I hope I didn't miss a step. If you can't get it to work let me know and I will retrace my steps and try again.

I am sending an image of some of the settings in case you aren't familiar with what I am talking about.

Untitled-3.jpg
Untitled-2.jpg
I forgot to add you have to choose Shape Burst from the Stroke menu.
If you want the image to have a more faded type gradient like in your image, go to the masks palette and choose the vector mask and add some feathering in the toolbar options.

Author

Commented:
@jeremy,  wow... definitely some work there!  I will have to test this out, but away from the project right at the moment.  Will do ASAP and advise... Thanks for your persistence!
No problem, I was able to get mine to have a more gradual gradient by playing with the feathering in the Masks Palette.

Author

Commented:
@Jeremy, playing with it and I now see how this is going to work, but if I Stroke the path, the part of the path that is not visible does not get Stroked and the outline is created around the visible part only (see screenshot) Is there a trick to this?
GradientLineExample.jpg
Yeah, I had that happen when I was trying to figure it out. I will have to go back and try it again to find the step that fixed it. I have a few things to take care of, then I will post the step.
OK, I believe the problem is in your gradient settings. If you have white in the center of the gradient this can cause the white inside the gradient like in the image you sent. I am sending my PSD file just in case it isn't the problem. Hopefully you can check my settings to resolve the difference. I am also sending a jpeg of the gradient settings I have chosen. You can change the gradient colors by going to: FX>Stroke, and click on your gradient bar to bring up the adjustment pop-up. Let me know if you have any issues or questions.

gradient-settings.jpg
sample.psd

Author

Commented:
No idea what happened on that one, but made a new path and restroked and filled (which I had not done previously - maybe that was it; it was treating the completed path as an individual line since there was no fill?) and it works!!!!  THANK YOU SO MUCH!
No problem. It was helpful for me also. I have never tried this, and after searching the internet for I couldn't find a good solution. I was starting to think maybe it wasn't possible. I've learned through trying to help you, so I gained as much as you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial