For an image editing application i’m trying to draw a gradient around a closed natural cubic spline.
The spline is drawn according to the algorithm and code explained here.
The outcome should look like this (created with GIMP using lots of gaussian blur).
As i could not find any suitable algorithm to determine the distance from the spline, i tought of the following algorithm:
- Mark some key points on the spline
- Grow or enlarge these points with reference to the center of the closed spline
- Create a mesh of triangles between the inner points and the outer points. These
triangles will have the inner vertexes black, and the outer vertexes
white.
As you can see, this solution is quite complex (will probably have to rely on OpenGL) and hence suboptimal.
Can anybody come up with a simpler solution?
Thanks in advance.
It seems you need to build distance transform map outside the spline. Some code for doing it. It is implemented in OpenCV library too.