0

Is it possible to create a gradient that strokes along a path?

My understanding is that CAGradientLayer or CGGradient will provide a gradient from, say, top to bottom. Since they don't support stroking along the path, I'm stumped.

I would even be OK with stretching an image (containing the gradient) along the path. Is that possible?

Example of desired stroke effect

In my case, I'd be stroking an arc (from CGPathAddArc). Is there a way to do this?

Graham Perks
  • 23,007
  • 8
  • 61
  • 83
  • 1
    Well, there is no built-in support for this, so what sort of answer are you looking for? – matt Jun 13 '16 at 17:00
  • After some more research, since I'm just doing this on an arc of a circle, I could probably make a shader for it, or use a mask with this project's output: https://github.com/tadija/AEConicalGradient. – Graham Perks Jun 13 '16 at 20:13
  • Getting some reassurance this is not built-in is actually a useful answer, thanks @matt!. – Graham Perks Jun 13 '16 at 20:16
  • "since I'm just doing this on an arc of a circle" Then that's what you should have asked! What you asked was illustrated with a specific shape to be stroked in a specific way. So that _wasn't_ in fact your question? – matt Jun 13 '16 at 23:51
  • I did say I was stroking an arc, which might offer a simpler solution. The image illustrates the more general case. – Graham Perks Jun 14 '16 at 11:42

0 Answers0