Gradiant to follow inside path?

Post questions on how to use or achieve an effect in Inkscape.
halkun
Posts: 5
Joined: Sun Jun 12, 2016 8:34 am

Gradiant to follow inside path?

Postby halkun » Wed Dec 20, 2017 6:37 am

I'm trying to get a gradient to follow the inside contour of an object. I can do the trick in Gimp, but I can't seem to get it to work in Inkscape.

I attached an example of what I'm trying to accomplish.

In Gimp:
Image

In Inkscape
Image

The gradient makes an ovoid shape and doesn't follow the outside. Is there a trick to get this to work?

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Gradiant to follow inside path?

Postby Lazur » Wed Dec 20, 2017 8:07 am

Hi.

With filtering you can build up a visual appearance of blurring the shape, utilizing its edges where the transparency drops.
That is the quickest workaround that has its limitations -no fill vector pdf-s, no accurate gradient steps, no resource-friendly rendering, no semi-transparent shapes, but it can be generated on any shape by an instant.
Here is an example for such a blurred solution, which got a diffuse filter added in.

Other workaround is having the image built up by flat filled shapes over eachother.
Can use some automation here, but it's way more tedious than the previous option.
You can either use interpolation to draw these objects based on the original path -and an additional one-, or explore gcodetools. Haven't tried it yet, but it seems capable generating parallel paths upon a given original.
Then, there is the extension to interpolate attribute within group. With that, you can fill the shapes in between with a "two colour gradient".
(The rearrange-restack extension may also come handy in the process to correct the z-ordering.)
A two coloured gradient might not be fitting, but there are other ways to change it to a gradient you are after.
You can generate a colourmap filter effect and apply it to a black to white gradient, or use the same extension to swap colours (just guessing here, haven't tried the latter though that option should work better certain cases).
This image was drawn with illustrator in the same vein -flat fills can be saved as eps too, so printing-wise this is the most "sturdy" you can get.

Thirdly, you can use mesh gradients -which are the most tedious editing-wise, and currently not part of the svg specs.
There is no real documentation of it besides Xav's article I know of. No update in the manual, may not make it into svg 2.0. You need to manually place mesh nodes one by one, there is no option to bend a gradient mesh along a path. (For that appearance, a tricky and crude solution is using custom markers, as discussed here -not sure what happened to the embedded image.)
Here is an example of using a gradient mesh.


Other option?
The most "hardcore" one is using linear and radial gradients to fit the shape.
Your second image can be drawn from a radial gradient and two linear ones within minutes.
The "flat filled" shapes method would fit your first image way better.
With all the "necessary overlapping" it can get real tricky.
For an example, have a look at this image.


Some cases you can combine those two methods (flat filled shapes and gradients) so that the complex gradient's steps can be edited by editing the gradient definition.
Here is an example for that. That is the rarest of them all, which I was experimenting with recently.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Gradiant to follow inside path?

Postby Lazur » Sun Jan 07, 2018 1:20 pm

Bumping this.
Maybe will also add some tags for the future because that's the essence of alot of gradient fill problems.

Did it help or am I just writing for my own amusement?

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Gradiant to follow inside path?

Postby brynn » Sun Jan 07, 2018 9:07 pm

I thought it was a thorough and well-thought answer.

I remember making an example using interpolation. But you posted before I finished, and since you mentioned interpolation already, I never posted the example.

Maybe the op was hoping for simpler solution?

Raspi
Posts: 229
Joined: Fri Oct 21, 2016 12:51 am

Re: Gradiant to follow inside path?

Postby Raspi » Sun Jan 07, 2018 9:39 pm

There is an easier method. Make an Inner Shadow.

01. Make a rectangle in the colour you want the shadow
02. with your shape, punch a hole in the shadow layer
03. group (optional, but good for position adjustment later)
04. blur
05. clip with shape

InnerShadow.png
InnerShadow.png (30.06 KiB) Viewed 1745 times

No disrespect to Lazur but his answers are way over the head of most users.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Gradiant to follow inside path?

Postby Lazur » Mon Jan 08, 2018 3:19 am

^-My first solution was exactly using blurring. Clipping and "punching hole" is not even necessary (as in the first linked example).

Raspi
Posts: 229
Joined: Fri Oct 21, 2016 12:51 am

Re: Gradiant to follow inside path?

Postby Raspi » Mon Jan 08, 2018 4:03 am

Lazur wrote:^-My first solution was exactly using blurring. Clipping and "punching hole" is not even necessary (as in the first linked example).

This is what im trying to say, your answer is way over most users head.
Yes, you talk about blurring, but also about filtering and adding a diffuse filter.
So i follow the link and i find a bunch of donuts.
Doesnt look much like what the gradient OP wants.
Also looking at that image doesnt give me the steps on how to make a donut and i have no idea how to make a filter.

How many of the regulars here, can make a custom filter, like you do ?


Return to “Help with using Inkscape”