Author Topic: How to apply gradient along each segment of a curve?  (Read 32 times)

June 14, 2018, 05:17:41 AM
Read 32 times


  • Newbie

  • Offline
  • *

  • 1
Say I have a white curve in black background:

The curve has some points cut it to separate segments. From point A in the line whose opacity is 100%, the transparency gradually increasing and then decreasing so that when it reach point B, the opacity is 100% again. The middle point of the segment, therefore, will be fadest. The longer the segment is, the fader the middle point is. This will repeat for other segments.

The idea is that when a pendulum swinging in the dark then in the extremes it is most visually clear, and its balance point is fadest, and the trajectory is gradiently going from clear to faded. I use Inkscape, but answers for other tools are welcomed, because I guess the terminology is the same.

An example made by Illustrator is provided by @Joonas in the same question asked on Stack Exchange, except that the slider points to the 100% opacity points, not 0.

Can this be done in Inkscape?
  • 0.48.5 r10040
  • Windows 7

June 14, 2018, 06:58:38 AM
Reply #1


  • Administrator

  • Offline
  • ******

  • 2,673
  • Gender

    • Inkscape Community
Oh wow!  Ok, I'm having a hard time making the transition between pendulum swinging in the dark, to the curved path that you're showing.  But unless a filter could be made to do this....I think the best approach would be Inkscape's Gradient Mesh tool.

We will need to hear from Lazur about the possiblity of a filter to do this (since he's our filters expert).  I'm guessing it would not be possible, but he always surprises me!

But the gradient mesh could definitely do this for you!  I don't know of any tutorials for that, since it's still relatively a new tool.  I could work on making one, but you'd probably have it figured out by the time I finish, haha.  Plus, you can ask questions here.

Have you used Inkscape's regular gradient tools yet?  They function in very similar ways.

You would not need several separate gradients.  The mesh allows you to set how many stops you need (which seem to be called "nodes", confusingly, in the gradient mesh).  Just be sure to either apply it to the stroke, or convert the stroke to path (Path menu).  Let's see if I can find the wiki article on it....  Ok, this might be it:

Let us know how it goes  :)
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     

"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

June 14, 2018, 01:07:25 PM
Reply #2


  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 966
  • Gender

Filtering is only based on screen pixels. The overall edges of a filled area has no real indication on it's direction.
Could use some blurring to generate an input for a diffuse shading, but that's pretty much about it. Can't bend a gradient, but can generate a diffuse shading of the same colours.

What else to try.
You can use a white stroked path for masking a group, so it'd make it possible adding in various objects with linear gradient fills, that make up the desired visual appearance.
If that's for printing as a pdf, clipping is the better supported solution. Then you'd need to convert the stroke to a path first.

Other hackish solution is representing the linear gradient with a vector halftone pattrern of paths above eachother with a flat fill,
grouping these objects and adding a bend path effect to the group.