How do I create a gradient transitioning colors from outside to inside of a path using Skia (Skiasharp)?

46 views Asked by At

I am trying to draw a gradient that transitions from one color at the outside of a path to another color on the interior of a path all the way around the path using SKiasharp. I've been playing with all the different gradient shaders, and I have checked out the samples, but none of the samples do what I'm trying to do. Right now, I can draw a solid color line around the path and then fill the path with another color, but I can't figure out how to create a gradient that transitions between the two colors. It seems like this should be easy - I think I could do it with GDI LinearGradientBrush and a Pen created from the brush - but I haven't yet figured out how to create the effect with Skia. Help from anyone experienced with using Skia shaders would be really appreciated!

Here's what I've done so far: enter image description here

I'd like to achieve something like this: enter image description here

As you can see in the 2nd image, there is a gradient from the outside of the path to the inside that is consistent all the way around the path. The path can be of any shape or size, and the gradient is consistent all the way around the path. I've tried various kinds of gradients (linear, radial, and conical), and even a dropshadow imagefilter and blur effects, but haven't been able to get any of them to create the kind of gradient I'm after.

0

There are 0 answers