Page 1 of 1

Adding a different gradient to stroke and fill of an object

Posted: Tue Jul 09, 2019 7:34 pm
by tobbAddol
Is there any way to do this easily? The gradient editor seems to be doing everything in its power to prevent me from getting there.

Also, is there any way to turn off the auto-clean feature for the gradients? I don't understand why I can't just create a gradient and keep it around for use later, and not have it disappear as soon as it's deselected.

Re: Adding a different gradient to stroke and fill of an object

Posted: Wed Jul 10, 2019 10:25 am
by Moini
Yes. Open the Fill and stroke dialog and choose different gradients for the fill and the stroke. With the gradient tool, make sure to not have the gradients linked.

There is no such autoclean feature, as far as I know. You need to trigger that with File > Clean up document, and for that you can set whether to remove swatches or not. What file format are you saving to?

Re: Adding a different gradient to stroke and fill of an object

Posted: Wed Jul 10, 2019 11:27 pm
by tylerdurden
Looks like my version of Inkscape (0.92.2) is deleting gradients that have no users.

That leaves a couple of options:
Make a copy of the object and hide it on a layer
Save the gradients as a swatches, but ensure the cleanup button is unchecked in preferences. Otherwise, the swatches will auto-prune (before cleanup) just like the gradients do.

InkscapeForum.com_-_Post_a_reply_-_Google_Chrome_2_2019-07-10_09-20-28.jpg
InkscapeForum.com_-_Post_a_reply_-_Google_Chrome_2_2019-07-10_09-20-28.jpg (201.44 KiB) Viewed 300 times

Notice that swatch #838 has zero users.

The attached SVG has one gradient, #884, that is not a swatch. If you delete that rectangle object, the gradient is also deleted. :-\

Re: Adding a different gradient to stroke and fill of an object

Posted: Fri Jul 12, 2019 2:23 am
by Moini
Okay, I checked, it's correct. However, gradients that you *name* will not be removed automatically. Give them a name in the editor, and they will stay, even when the object is removed.

Re: Adding a different gradient to stroke and fill of an object

Posted: Fri Jul 12, 2019 3:14 am
by tylerdurden
Moini wrote:...gradients that you *name* will not be removed automatically. Give them a name in the editor, and they will stay, even when the object is removed.


I was so excited, but alas, I must be doing something wrong. Named gradients also seem to go away when I delete a single user.

2019-07-11_13-10-07.gif
2019-07-11_13-10-07.gif (248.98 KiB) Viewed 260 times


:(

Re: Adding a different gradient to stroke and fill of an object

Posted: Fri Jul 12, 2019 6:13 am
by Moini
Works for me. What version?

Re: Adding a different gradient to stroke and fill of an object

Posted: Fri Jul 12, 2019 6:15 am
by Moini
Oookay. Work*ed* for me. What's that?...

Re: Adding a different gradient to stroke and fill of an object

Posted: Fri Jul 12, 2019 6:17 am
by Moini
It works *sometimes*...

Re: Adding a different gradient to stroke and fill of an object

Posted: Fri Jul 12, 2019 6:19 am
by Moini
Okay. The difference is that if I edit the gradient with the legacy gradient editor, it will not be cleaned out.

Re: Adding a different gradient to stroke and fill of an object

Posted: Fri Jul 12, 2019 6:19 am
by Moini
It's not the name at all.

Re: Adding a different gradient to stroke and fill of an object

Posted: Fri Jul 12, 2019 6:26 am
by Moini
There's the property 'inkscape:collect' set to 'always' on gradients edited with the old gradient editor. This property is not added to gradients that are edited on canvas only.

Re: Adding a different gradient to stroke and fill of an object

Posted: Fri Jul 12, 2019 8:25 am
by tylerdurden
I'm still running 0.92.2 on Win 8.1.

I used the legacy editor and also named the gradients, and.... it still purges the gradients from the defs when I delete the last user of a gradient.

At least the swatches are available as a fallback.

Re: Adding a different gradient to stroke and fill of an object

Posted: Fri Jul 12, 2019 8:43 am
by Moini
Hm... That works for me, using 0.92.4 on Linux Mint 19 Tara. But it seems it's not intended to work - in 2013, someone removed that, so as not to clutter memory and gradient list with unused things.

Swatches would be the intended alternative, if they worked so well that one could trust them.

Problem with swatches is that:

- they fork gradients on edit (https://gitlab.com/inkscape/inbox/issues/648) (maybe that depends on the preferences setting for linking gradients)
- they don't keep radial gradients (https://gitlab.com/inkscape/inbox/issues/647)
- and probably many usability issues and other bugs ...

Re: Adding a different gradient to stroke and fill of an object

Posted: Fri Jul 12, 2019 8:43 am
by Moini
Oh, I also submitted a feature request for a 'last used styles' list.

Re: Adding a different gradient to stroke and fill of an object

Posted: Sat Jul 13, 2019 2:08 am
by tylerdurden
Here's what I see happening...

With the new gradient editor, the inkscape:collect attribute is added to any new parent gradient, and to any duplicates made from that parent. The attribute causes the gradients to purge when the last object using the gradient is deleted.

This can be overcome by deleting the attribute on the parent gradient in the defs, using the XML editor. A duplicate of the edited gradient can be spawned without the attribute, by using the plus-sign in the Fill/Stroke dialog, or by using the edited parent gradient on another object, then changing its colors to create new gradients.

Gradients without the attribute will still be removed when the document is cleaned, if no objects are using them.

Another way to remove the attribute is to use the legacy gradient editor, but the process must use the edit-gradient button in the Fill/Stroke dialog.

Re: Adding a different gradient to stroke and fill of an object

Posted: Sat Jul 13, 2019 7:47 am
by Moini
So that's basically the opposite from what I saw... I'm confused, but too tired to re-check at the moment. Patrick suggested to make a bug report about this, as the inconsistent behaviour is strange, so devs could figure out what to do, and decide if they should do anything about it. Would you like to make one, tylerdurden?

Re: Adding a different gradient to stroke and fill of an object

Posted: Sat Jul 13, 2019 9:29 am
by tylerdurden
Moini wrote:Patrick suggested to make a bug report about this, as the inconsistent behaviour is strange, so devs could figure out what to do, and decide if they should do anything about it. Would you like to make one, tylerdurden?

Will do.

Re: Adding a different gradient to stroke and fill of an object

Posted: Sat Jul 13, 2019 10:41 pm
by tylerdurden

Re: Adding a different gradient to stroke and fill of an object

Posted: Mon Jul 15, 2019 3:13 am
by Moini
Thank you!