recolouring a gradient

Post questions on how to use or achieve an effect in Inkscape.
JuliaFlowers2
Posts: 18
Joined: Tue Jul 31, 2018 4:47 am

recolouring a gradient

Postby JuliaFlowers2 » Thu Aug 09, 2018 10:31 pm

Dear friends,

i have made text with a gradient on each letter. They are not all at the same angle.

Two questions:

1.) although each letter has the same black-to-transparent gradient, i have several (nine) gradients in the Fill tab.
Why is that ?

2.) i want to re-colour the black gradient to a dark green. How can i do this with one action so i dont have to do it nine times ?

User avatar
Xav
Posts: 1122
Joined: Fri May 08, 2009 1:18 am
Location: UK
Contact:

Re: recolouring a gradient

Postby Xav » Thu Aug 09, 2018 11:10 pm

When creating a gradient using the :tool_gradient: tool there is a drop-down list of existing gradients for you to select from if you want to reuse an existing one. Alternatively, in the Fill & Stroke dialog you can select an existing gradient (there's also a column showing the number of objects using each gradient, which can be helpful when trying to switch lots of similar gradients to one common one).

By default, as soon as you change the gradient on an element Inkscape will create a new copy of the gradient to modify instead. This is done to avoid surprises when a user modifies the gradient on one element in an image only to be surprised that something in a completely different part of the document has changed. This default behaviour can be changed by un-ticking "Prevent Sharing of gradient definitions" in Edit ‣ Preferences ‣ Tools ‣ Gradient.

With the "prevent sharing" option off, changes to the colour stops of one gradient will affect all uses of that gradient. In your case you'll have to switch all 9 letters to use the same gradient definition first, but then it should behave the way you expect.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter

tylerdurden
Posts: 2106
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: recolouring a gradient

Postby tylerdurden » Thu Aug 09, 2018 11:56 pm

If you have separate objects, you can group them and apply a single gradient to the group.

Image

If you ungroup them after, to edit the gradient for all in unison, you must change the preferences for gradient sharing.
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/

JuliaFlowers2
Posts: 18
Joined: Tue Jul 31, 2018 4:47 am

Re: recolouring a gradient

Postby JuliaFlowers2 » Fri Aug 10, 2018 12:36 pm

tylerdurden wrote:If you have separate objects, you can group them and apply a single gradient to the group.
If you ungroup them after, to edit the gradient for all in unison, you must change the preferences for gradient sharing.

Dear tylerdurden,
this is not what my text is like. I have one gradient from black to transparent on every letter, but they are all at different angles.
So i cant just use one gradient on a group.

What i dont understand is why i have so many gradients in the Fill & Stroke Dialogue, when its always the same colour.


Xav wrote:By default, as soon as you change the gradient on an element Inkscape will create a new copy of the gradient to modify instead.

What exactly does "change" mean here ??
A different angle or different colours ? Or both ?

In your case you'll have to switch all 9 letters to use the same gradient definition first, but then it should behave the way you expect.

I was able to get rid of a lot of duplicate gradients by reapplying the gradient, so im now down to 18 objects sharing the same gradient, but there are still 4 left that i have no idea where they belong. None of the objects in my image do seem to have them applied.

I tried to hoover the document, but they are still there....

What do the gradient names (numbers) mean ?
Are they searchable ?

User avatar
Xav
Posts: 1122
Joined: Fri May 08, 2009 1:18 am
Location: UK
Contact:

Re: recolouring a gradient

Postby Xav » Mon Aug 13, 2018 2:59 am

JuliaFlowers2 wrote:
Xav wrote:By default, as soon as you change the gradient on an element Inkscape will create a new copy of the gradient to modify instead.

What exactly does "change" mean here ??
A different angle or different colours ? Or both ?


Did you try to find out? It's pretty easy to see by drawing a couple of rectangles that use the same gradient that changes to the position of the end stops on the canvas makes no difference, but as soon as you modify the colours, or add/remove/move intermediate stops, a duplicate is created.


JuliaFlowers2 wrote:I was able to get rid of a lot of duplicate gradients by reapplying the gradient, so im now down to 18 objects sharing the same gradient, but there are still 4 left that i have no idea where they belong. None of the objects in my image do seem to have them applied.


I've spent many, many hours trying to reduce large numbers of gradients to a few shared definitions (my "Greys" comics are full of similar gradients that I try to share between objects where possible). My best advice is to do the following:

1) In Edit ‣ Preferences ‣ Tools ‣ Gradient enable the "Use Legacy Gradient Editor" option
2) Draw a temporary rectangle. With it selected, go to the Fill & Stroke dialog and apply one of the gradients you're looking for to it.
3) In the Fill & Stroke dialog, select the gradient then click the edit button to get to the legacy gradient editor dialog.
4) In the gradient editor, change your stop colours to something suitably bright and garish that will make them stand out from the other objects in your image.
5) Hopefully this will be enough for you to see what object is using the gradient. You can then select the object and assign it to a different gradient. Once the "use count" in the F&S dialog drops to 1 (representing the temporary rectangle you created) you can delete the rectangle and the gradient should be removed.

This method isn't perfect. Sometimes Inkscape can lose track of the connections between objects and gradients, especially if you've done a lot of editing, modifying and reassigning of gradients. More often the gradient is in use, but isn't visible because the object it's used on is transparent, or is hidden behind something else (accidental duplications are a good source of this). In those cases you can either give up, or start sleuthing your way through the XML file…

JuliaFlowers2 wrote:What do the gradient names (numbers) mean ?
Are they searchable ?


They are automatically assigned by Inkscape, and correspond to the ID of the gradient definition in the XML. E.g. a name of "38" corresponds to an id of "linearGradient38" or "radialGradient38". You can rename them in the F&S dialog if you wish, which also renames the ID in the XML for you.

They are searchable (easier if you use the full ID with the "linearGradient" or "radialGradient" prefix, or if you've renamed them), but that won't necessarily help. Inkscape tends to indirectly reference gradients: e.g. an object might have "fill:url(#radialGradient853)" in its style properties, but if you find the element with ID "radialGradient853" you'll discover that it, in turn, has an xlink:href attribute that references another gradient. With an understanding of XML and SVG it's possible to manually clean any unused gradients out of the file - or to work out where they're being used - but it's not as simple as just punching the gradient's number into the Find & Replace dialog.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter

JuliaFlowers2
Posts: 18
Joined: Tue Jul 31, 2018 4:47 am

Re: recolouring a gradient

Postby JuliaFlowers2 » Mon Aug 13, 2018 1:46 pm

Xav wrote:
JuliaFlowers2 wrote:
Xav wrote:By default, as soon as you change the gradient on an element Inkscape will create a new copy of the gradient to modify instead.

What exactly does "change" mean here ??
A different angle or different colours ? Or both ?


Did you try to find out? It's pretty easy to see by drawing a couple of rectangles that use the same gradient that changes to the position of the end stops on the canvas makes no difference, but as soon as you modify the colours, or add/remove/move intermediate stops, a duplicate is created.

Dear Xav, thank you for getting back to me.

Yes, i did try and thats what threw me off, so i needed to know for sure.
All i did was use a black-to-transparency gradient repeatedly, with no additional stops, still Inkscape produced multiple gradients.

(accidental duplications are a good source of this).

This might be the case...hard to verify.

Xav wrote:
JuliaFlowers2 wrote:What do the gradient names (numbers) mean ?
Are they searchable ?


They are automatically assigned by Inkscape, and correspond to the ID of the gradient definition in the XML. E.g. a name of "38" corresponds to an id of "linearGradient38" or "radialGradient38". You can rename them in the F&S dialog if you wish, which also renames the ID in the XML for you.

I can not confirm this.
My gradient is applied 18 times to a path. In the Fill & Stroke Dialogue its named 1175, but in the XML editor it goes by the name of #linearGradient1183.

User avatar
Xav
Posts: 1122
Joined: Fri May 08, 2009 1:18 am
Location: UK
Contact:

Re: recolouring a gradient

Postby Xav » Mon Aug 13, 2018 5:19 pm

JuliaFlowers2 wrote:All i did was use a black-to-transparency gradient repeatedly, with no additional stops, still Inkscape produced multiple gradients.


I think I can see where the confusion comes from. If you draw a gradient on an object, a new gradient will be created. It doesn't matter what colour the stops are, Inkscape always creates a new gradient. That's not the situation I've been talking about.

If, however, you select an existing gradient from the dropdown, it won't create a new gradient, even if you move the end stops. It will only create a new one when you change the colours or add/remove/move intermediate stops.

Try these steps to confirm (this assumes that the option to prevent sharing of definitions is off):

1. In a new file draw three rectangles.
2. Use the :tool_gradient: tool to set the fill of the first rectangle to a gradient.
3. Switch back to the :tool_selector: tool, then open the F&S dialog and note that the fill is set to a gradient, it's the only one in the list, and the "#" column shows 1 use.
4. Select the second rectangle, give it a gradient (with the same end colours), note that the F&S dialog shows two similar gradients, each used once.
5. Repeat for the third rectangle.
6. Let's suppose Inkscape has named the three gradients 15, 23 and 37 (probably in reverse order).
7. Now, with the second rectangle selected, switch to the :tool_gradient: tool and the drop-down list on the toolbar should show that it's using gradient 23. Pick 15 from the drop-down list to switch it to use the first gradient definition.
8. Notice that, in the F&S dialog the number of gradients has reduced to 2, and that gradient 15 now shows 2 uses. Also the drop-down list only shows 2 entries now.
9. Select the third rectangle, and click on gradient 15 in the F&S dialog. This is an alternative to using the drop-down. You should now only have a single gradient definition, used 3 times.
10. Make an edit to the angle of the gradient in the second and third rectangles - no new gradient definitions are created. You can even change the state of the "Repeat" option in the gradient toolbar, and still the same gradient definition is used.
11. Make a change to a stop colour, or add another stop, and a new gradient definition is created.


JuliaFlowers2 wrote:
They are automatically assigned by Inkscape, and correspond to the ID of the gradient definition in the XML. E.g. a name of "38" corresponds to an id of "linearGradient38" or "radialGradient38". You can rename them in the F&S dialog if you wish, which also renames the ID in the XML for you.

I can not confirm this.
My gradient is applied 18 times to a path. In the Fill & Stroke Dialogue its named 1175, but in the XML editor it goes by the name of #linearGradient1183.


As I said in my previous reply (when I noted that searching wouldn't be much use): "Inkscape tends to indirectly reference gradients: e.g. an object might have "fill:url(#radialGradient853)" in its style properties, but if you find the element with ID "radialGradient853" you'll discover that it, in turn, has an xlink:href attribute that references another gradient."

In other words, if you look for "linearGradient1183" in the <defs> section of the XML, you'll probably find that the gradient with that ID does not contain any child nodes (the stop definitions), but instead it has an "xlink:href" attribute that points to "#linearGradient1175". That bit of redirection is how gradient definitions are shared - the directly referenced gradient contains the coordinates of the end stops, whilst the indirectly referenced one holds the color definitions of the stops.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter

JuliaFlowers2
Posts: 18
Joined: Tue Jul 31, 2018 4:47 am

Re: recolouring a gradient

Postby JuliaFlowers2 » Mon Aug 13, 2018 7:57 pm

Xav wrote:I think I can see where the confusion comes from. If you draw a gradient on an object, a new gradient will be created. It doesn't matter what colour the stops are, Inkscape always creates a new gradient. That's not the situation I've been talking about.

If, however, you select an existing gradient from the dropdown, it won't create a new gradient, even if you move the end stops. It will only create a new one when you change the colours or add/remove/move intermediate stops.

Try these steps to confirm (this assumes that the option to prevent sharing of definitions is off):


Thank you Xav !
So it was my workflow that lead to this. I had no idea !

One last question:
is it possible to change the angle of the gradient in the XML editor ?

User avatar
Xav
Posts: 1122
Joined: Fri May 08, 2009 1:18 am
Location: UK
Contact:

Re: recolouring a gradient

Postby Xav » Mon Aug 13, 2018 8:34 pm

JuliaFlowers2 wrote:So it was my workflow that lead to this. I had no idea !


Inkscape follows the "principle of least surprise" in this regard. It tends to create new gradients so that changes to one won't surprise a user by also changing an object in a different part of their drawing when they didn't expect it to. You have to take some specific steps to avoid this default behaviour, if that's not what you want.

JuliaFlowers2 wrote:is it possible to change the angle of the gradient in the XML editor ?


Inasmuch as everything can be changed in the XML editor, yes. But that doesn't make it a friendly way to do it.

In the case of the gradient angle, it's not set as an angle - rather the x and y coordinates of the end stops are stored. So you can change the angle by altering the x and y values for the end stops, but there's no single "angle" value you can change: if you want a specific angle you'll have to do a bit of trigonometry to calculate the new coordinates you'll need.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter

tylerdurden
Posts: 2106
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: recolouring a gradient

Postby tylerdurden » Tue Aug 14, 2018 9:37 am

Guidelines can also be used to snap the gradient handles to a particular angle, and guideline angles are easy to set in the GUI.
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/


Return to “Help with using Inkscape”

Who is online

Users browsing this forum: No registered users and 6 guests