Duplicate object with gradient: Edit 1 gradient = edit both?

Post questions on how to use or achieve an effect in Inkscape.
User avatar
ianp5a
Posts: 106
Joined: Thu Sep 02, 2010 1:30 am

Duplicate object with gradient: Edit 1 gradient = edit both?

Postby ianp5a » Sun Jun 29, 2014 10:45 pm

This has been driving me mad. But I think I've solved it. But why?
  • Create a shape and add a gradient.
  • Duplicate (CTRL-D) the shape and move it.
  • Edit the gradient and change some colours.
  • See the gradient of the original shape changes too! Not what I want.
  • The colours and number of nodes is the same.
  • The position and direction of the nodes in independent.
Repeat these steps but use Copy/Paste instead of Duplicate. See the gradients are independent. Hooray!
Note: If you do use the one-step Duplicate (CTRL-D) you can separate the gradients using the Duplicate button on the gradient editor.
So this leaves me with the problems:
  • A quick one-step duplicate is not available. Slower.
  • Linked gradients cannot be spotted easily. Dangerous.
  • Linking gradients must be a niche feature and not the default.
  • I call this "quirky" and un-obvious. Am I missing something?

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

Re: Duplicate object with gradient: Edit 1 gradient = edit b

Postby Lazur » Sun Jun 29, 2014 11:00 pm

That is a very handy feature most of the time.
By having each object with separate gradients, there can be ALOT of defs in the svg you make, which may not render well outside inkscape.

Here is an example svg with many separate gradients:
SVG Image


Here is another svg, with only four gradients used:
SVG Image

And, because there were only four gradients used, it could be recolourized quickly:
SVG Image
SVG Image

Edit:
Oh and by the way these baskets I made otiginally for the container drawing challenge at inkscape community.

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

Re: Duplicate object with gradient: Edit 1 gradient = edit b

Postby brynn » Sun Jun 29, 2014 11:57 pm

In Inkscape Preferences > Misc, there's a setting "Prevent sharing of gradient definitions". So you can check that box, and then whenever you duplicate an object with a gradient, the duplicate gets a different gradient, which won't change when you edit the gradient on the original object.

There are advantages and disadvantages either way, depending on your particular needs. As Lazur points out, sharing gradient definition can help keep file sizes low. Otoh, as you discovered, it can cause objects color to be changed inadvertently, which can be quite annoying.

When I first started using Inkscape, gradient defs where shared by default, with no choice otherwise. But in some fairly recent version, developers gave us the choice (although I don't know why it's under Inkscape Prefs > Misc, instead of Inkscape Prefs > Gradients :roll: ). (Maybe that's where it is in the dev version, Idk.) I used to keep mine permanently not shared. But more recently, I've found that it can be helpful, in certain images, to allow the sharing. So now, I make a choice before I start a new image, depending on the image.

That's an interesting discovery you made about Duplicate vs Copy/Paste. I wasn't aware of that! But it will be helpful to know that now, because instead of changing the Inkscape Prefs setting, which is more or less global, if I have just 1 instance where I need a gradient def not to be shared, I could just copy and paste instead of duplicating.

User avatar
ianp5a
Posts: 106
Joined: Thu Sep 02, 2010 1:30 am

Re: Duplicate object with gradient: Edit 1 gradient = edit b

Postby ianp5a » Mon Jun 30, 2014 1:02 am

Thanks both

I didn't know about Preferences - Prevent sharing. But for me it was already checked! It is not working. (bug?)

1) Anyway, duplicate and copy/paste would be expected to produce the same result. If copying the gradient is required for duplicate by default, it is also required for copy/paste by default. To fix it, 2 separate preferences should be available, so every option is available. This is "quirky" operation where Learn-ability is down.

2) If linked gradients is an important feature, then post-linking, unlinking and an easy way to detect and manage linked gradients should also be available. I have been adjusting gradients not knowing that I was also changing other objects elsewhere. Which is dangerous.

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

Re: Duplicate object with gradient: Edit 1 gradient = edit b

Postby Lazur » Mon Jun 30, 2014 1:37 am

An ugly but effective way to separate gradients as they are on existing drawings is to save as pdf then reopen and edit that file.

Another workaround would be to use the tweak tool in colour mode on all objects with the same gradient.
By changing them a bit they will be stored in separate ones.

There is a known bug where each small edit of a gradient gets stored separately, resulting in hundreds or gradient definitions, mostly unused.
Which to may experience can crash inkscape easily (Maybe it's a similar based problem as the pattern fill's with garbage collector?).
That is why I would recommend not to use many different gradients in a drawing.

User avatar
ianp5a
Posts: 106
Joined: Thu Sep 02, 2010 1:30 am

Re: Duplicate object with gradient: Edit 1 gradient = edit b

Postby ianp5a » Mon Jun 30, 2014 2:13 am

Thanks for those tips.
I have discovered more:
  • If you move either end point, it does not break the link.
  • If you move an internal point, it automatically breaks the link. You now have a separate gradient.
  • If you want linked gradients for global editing you can't move any point globally. It works only for colour editing. I guess a clone is then needed.

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

Re: Duplicate object with gradient: Edit 1 gradient = edit b

Postby Lazur » Mon Jun 30, 2014 2:26 am

ianp5a wrote:
  • If you want linked gradients for global editing you can't move any point globally. It works only for colour editing. I guess a clone is then needed.


For that you need to edit the gradient with the gradient editor, and not the step handles with the node tool.

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

Re: Duplicate object with gradient: Edit 1 gradient = edit b

Postby brynn » Mon Jun 30, 2014 2:38 am

Ok. I don't know if there may be a bug involved or not. Here's my testing with the current stable version:

With "Prevent sharing...." unchecked, allowing sharing of gradient defs, when you duplicate an object, it gets the exact same gradient. If you edit the gradient in the original object, it gets edited in the duplicated object.

When the original object with gradient is copied and pasted, the copy/pasted object gets a new gradient number. Well it's the same number with a dash and another number, such as 1234-4. But when the gradient in the original object is edited, it's not changed in the copy/pasted object.

With "Prevent sharing...." checked, and you duplicate an object, it does get a gradient with the same number ID as the original object. But when you edit the gradient in the original object, the gradient in the duplicated object does not change. And at the moment you edit the original gradient, it gets a new ID number. The duplicated object's gradient does not change, and retains the original ID number.

When the original object is copy/pasted, it's the same, whether gradients are set to be shared or not.

It does seem odd to me, that when "Prevent gradient def sharing" is checked, when you duplicate an object, its gradient has the same ID number as the original. It would seem to me more logical if the duplicate got a new ID number, at the moment of duplication. Perhaps that part is a bug, I don't know. But the way it is, whichever gradient is edited gets the new ID number. That does make sense. I agree that the duplicate initially getting the same ID number seems confusing. But I guess it's because, until one of the 2 objects' gradients is edited, the ARE the same gradient.

Duplicate and Copy are NOT the same thing. If they were the same thing, there wouldn't be any use for one or the other. But since they both exist in Inkscape, it makes sense that they are different, in some way. I can't explain, technically.....or even simply (lol)) what is the difference. But I would not expect them to necessarily act the same way, even though they seem to do very similar things.

Opps, 2 more messages while I'm typing.

Moving the end stops of a gradient does not make it a new gradient (when Prevent Sharing is enabled). I can't explain why. Maybe bug, I don't know.
(You can search the bug tracker, if you're interested. https://launchpad.net/inkscape)

Yes, if you want global editing, you'll need to use clones.

User avatar
ianp5a
Posts: 106
Joined: Thu Sep 02, 2010 1:30 am

Re: Duplicate object with gradient: Edit 1 gradient = edit b

Postby ianp5a » Mon Jun 30, 2014 2:53 am

Lazur URH wrote:
ianp5a wrote:
  • If you want linked gradients for global editing you can't move any point globally. It works only for colour editing. I guess a clone is then needed.

For that you need to edit the gradient with the gradient editor, and not the step handles with the node tool.


Yes. I see now. On the object directly, it breaks the link. Via the slider on the GUI it keeps the link. Another inconsistency that most people will never discover.

On my (stable) version the 'Prevent' setting has no effect on Duplicate or Copy/Paste.

On copy/paste it always creates an independent gradient with a slightly different (dash) number.

On most software copy/paste and duplicate are the same. If there is supposed be a difference, then it needs to be made clear to the user. Often with a checkbox in a GUI. If Inkscape has always done those differently it does not mean it is in any way right or good. Learn-ability and clarity is just as important in Inkscape as in any other software.

User avatar
ianp5a
Posts: 106
Joined: Thu Sep 02, 2010 1:30 am

Re: Duplicate object with gradient: Edit 1 gradient = edit b

Postby ianp5a » Mon Jun 30, 2014 3:09 am

brynn wrote:Yes, if you want global editing, you'll need to use clones.

Yes or use copy + Paste Style. Which keeps the gradient colour and spacing. And, when pasted onto multiple targets creates linked gradients again.

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

Re: Duplicate object with gradient: Edit 1 gradient = edit b

Postby brynn » Mon Jun 30, 2014 8:13 am

ianp5a wrote:On my (stable) version the 'Prevent' setting has no effect on Duplicate or Copy/Paste.


Do you mean as far as the ID number? It's not supposed to affect copying, afaik.

For Duplicate, after you edit the gradient on 1 of the 2 objects (original or duplicate), the Id number then should change on the one you edited. (As I said before.)

ianp5a wrote:Learn-ability and clarity is just as important in Inkscape as in any other software.


Well, of course it is. You may find that Inkscape has a lot of such "quirks". I haven't ever used Adobe Illustrator, so I can't compare them, as far as how intuituve they are to learn. But I suspect Illustrator is no better than Inkscape, in this regard. However, I first started with computer graphics in a raster editor (GIMP). And I found Inkscape and vector graphics MUCH more intuitive to learn!

But I always like to point out that Inkscape is still very much under active development, and still has not reached a version 1.0. I'm sure the development team would welcome any input by qualified coders ;)

User avatar
ianp5a
Posts: 106
Joined: Thu Sep 02, 2010 1:30 am

Re: Duplicate object with gradient: Edit 1 gradient = edit b

Postby ianp5a » Mon Jun 30, 2014 9:19 pm

brynn wrote:Do you mean as far as the ID number? It's not supposed to affect copying, afaik.
For Duplicate, after you edit the gradient on 1 of the 2 objects (original or duplicate), the Id number then should change on the one you edited. (As I said before.)

On Inkscape 0.48.4 r9939 on Windows and also on Linux having the "Prevent" checkbox active makes no difference to Duplicate (CTRL-D). The gradients are linked until you use the Gradient Duplicate button on the Fill /Stroke Panel.

brynn wrote:I first started with computer graphics in a raster editor (GIMP). And I found Inkscape and vector graphics MUCH more intuitive to learn!
I started on 3D software. Then I used CorelDraw, Illustrator and Freehand. CorelDraw and Freehand were way better than illustrator. People it only bought because they knew Photoshop. It might be better since they poached Freehand though. Inkscape desperately needs a decent object manager like CorelDraw to catch up though. The XML editor is not OK.
brynn wrote:I'm sure the development team would welcome any input by qualified coders ;)

Ah. I can't help there. And I'm sure they have enough testers/reviewers, which where I could help. Which I do in my day job for a 3D software company.

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

Re: Duplicate object with gradient: Edit 1 gradient = edit b

Postby brynn » Sat Jul 05, 2014 2:22 pm

ianp5a wrote:On Inkscape 0.48.4 r9939 on Windows and also on Linux having the "Prevent" checkbox active makes no difference to Duplicate (CTRL-D). The gradients are linked until you use the Gradient Duplicate button on the Fill /Stroke Panel.


I'm using the same Inkscape version on Win7. And the Prevent setting does work for me. Try with the Prevent checkbox checked and duplicate an object with a gradient fill. At first, both objects appear to have the same gradient, by the ID number. (Idk if having the same ID number means they are still linked.) Without clicking Duplicate gradient button, edit one of the gradients by changing the color of one of the stops. Whichever gradient you edited will now have a new ID number, and the other object did not get the same change.

Idk why moving an end stop isn't considered to be changing the gradient. Maybe there's a bug or something? I'd have to do some research there.

Without the Prevent setting box checked, editing 1 gradient also affects the other object.

I mean, it sounds like you're well equipped to be able to spot and document and report bugs. And of course, as an open source project, you're welcome to submit a bug report, if you like. I'm certainly no expert as far as bugs!

I agree about the need for an object manager, for sure! And Idk if they have enough testers or not? I just happened to find a testing mailing list, which I never knew about before subscribe and archives


Return to “Help with using Inkscape”