4

I'm hoping to find a way to follow a path with a gradient so that the gradient changes along a tangent to the path.

Sorta like this: enter image description here

So far, however, the solutions I've found in my search have all used variations on using a shape layer to mask a gradient layer.

Which results in an unwanted variation like this: enter image description here

Is there a way to do this with Cocoa? In a way which will lend itself to animating changes to the path's shape?

xi golom
  • 351
  • 1
  • 3
  • 9
  • This question seems promising: http://stackoverflow.com/questions/15866179/draw-segments-from-a-circle-or-donut/15868472#15868472 – Quxflux Sep 25 '14 at 19:13
  • I think you can turn your path into a dotted path and then manipulate all individual dots in terms of colour, size and so on. So you simply move through an array of dots cycling through your colour pattern. I have some code at home that uses that line-to-dots strategy, I can look it up and paste it in a while if you want. – Lucas van Dongen Sep 25 '14 at 20:49
  • Lukas, your linked SO question and a few others can simulate what I'm wanting to accomplish in a few simple cases for arcs and lines, but it won't work for my example path. Thanks, however, for jumping in and trying to help. Departamento B's idea is interesting. If I can get a smooth gradient from a collection of thin dashes without requiring too much processing for all of the parts during animation, then it may work. I'd very much like to see your code, DB. Thanks. – xi golom Sep 25 '14 at 20:57

0 Answers0