2 problems with gradient

Post questions on how to use or achieve an effect in Inkscape.
v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

2 problems with gradient

Postby v1nce » Thu Jul 04, 2013 5:53 am

Hi,

I should be missing something...

1) There's no way to move object with their gradient without resizing ?

If I uncheck "transform gradient with objects" then the gradient is stucked to the background = I see it through the object (=no good)
If I check "transform gradient with objects" then the gradient follows the object (good) but when I resize the object the gradient stretch to accomodate the new size (no good)

2) Is it possible to enlarge the gradient without stretching it ?

Say my gradient is 100 px wide with 3 nodes at 0,50,100. Can I enlarge it to 150 without the second node moving to 75 ?

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

Re: 2 problems with gradient

Postby Lazur » Thu Jul 04, 2013 6:04 am

Isn't moving the object with the "gradient fill when transform gradient with object" turned on,
then scaling it with "transform gradient with object" turned off produces the right result?

If no, you can use guide lines, to snap the gradient's handles in any case.

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: 2 problems with gradient

Postby v1nce » Thu Jul 04, 2013 7:01 am

Sorry for the approximate translation

Lazur URH wrote:Isn't moving the object with the "gradient fill when transform gradient with object" turned on,
then scaling it with "transform gradient with object" turned off produces the right result?


Yes that works.
This doesn't fit with my workflow but it works.

Lazur URH wrote:If no, you can use guide lines, to snap the gradient's handles in any case.


Sorry I really don't get this one.

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

Re: 2 problems with gradient

Postby Lazur » Thu Jul 04, 2013 7:27 am

In your example you mentioned a gradient which was originally 100 pixels wide, but there was no information how it was made, what object had that as a fill.
I was thinking you wanted a gradient with each steps at exact positions,
so why not have guidelines for those positions?
In the example, if it was a rectangle that was 100 pixels wide, drawn at (0;0), why not adding guidelines at x=0, x=50, x=100?
Or for whatever the end handle you want it to be enlarged, like x=150.
If there are three guidelines drawn that way, you can snap the gradient's steps to them while in node editor mode.

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: 2 problems with gradient

Postby v1nce » Thu Jul 04, 2013 8:21 am

2x post error
Last edited by v1nce on Thu Jul 04, 2013 8:30 am, edited 1 time in total.

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: 2 problems with gradient

Postby v1nce » Thu Jul 04, 2013 8:29 am

Lazur URH wrote:In your example you mentioned a gradient which was originally 100 pixels wide, but there was no information how it was made, what object had that as a fill.
I was thinking you wanted a gradient with each steps at exact positions,

so why not have guidelines for those positions?
In the example, if it was a rectangle that was 100 pixels wide, drawn at (0;0), why not adding guidelines at x=0, x=50, x=100?
Or for whatever the end handle you want it to be enlarged, like x=150.
If there are three guidelines drawn that way, you can snap the gradient's steps to them while in node editor mode.


Fool me. I was thinking you wre still referring to problem 1.

I got a reference image of a side view of a cylinder with a 'chrome' gradient.
If the bands were perfectly vertical, I'd used a linear gradient set the nodes at transition and voila.

But because of a pseudo 3d effect some bands are vertical (on external side of the cylinder) and the others are at 45° (at the inner of the cylinder).
That can be (cleverly :) and painfully :) ) approximated using a radial gradient with an offseted center and unequal width for X and Y.
200% more work for 20% better result :)
Playing with both the nodes position along the axis + the position of the center take time but I ended with something good except I would need a extra node at 110% of current length of X (or Y) axis.

So I got x nodes unequally spaced along the axis (with some nodes overlapping for sharp transistion of color).
Say the current axis length is 100 (100 pixels or 100% if you want) for now.
I need to add an extra node at 110.
If I drag the last node to enlarge the gradient then all the nodes will stretch to accomodate the new size.

if nodes positions were
0, 10, 25, 40, x, 100

positions will become
0,11, 27.5, 44, 1.1x, 110

I guess I could :
set 30 guidelines at 0,10, 25, 40... [*]
resize the gradient
replace each of 30 nodes at his previous location by hand using the guides
remove the guides
but I'd definitively preferred some magic key combination that allows to resize the gradient without stretching position of existing nodes.

* = I guess there's no shortcut to add a vertical/horizontal guide that pass through the selected node of a gradient

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: 2 problems with gradient

Postby v1nce » Thu Jul 04, 2013 8:35 am

read stop everywhere I used node.

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

Re: 2 problems with gradient

Postby Lazur » Thu Jul 04, 2013 8:59 am

Now I get what you are looking for.

Looked at a gradient in the codes of an svg, the steps are defined in a percentage offset way,
wich doesn't relate to any coordinates of the svg but the gradient.
From that I assume there is no way of adding new steps outside the existing length of the gradient,
because that would change all the precentage values of the previous steps.
Well that makes it possible to calculate some things manually and edit the svg via notepad, like
dividing all the steps percentage by two in the codes, then,
in inkscape scaling down the object by 50% with the "transform gradient with object" turned off,
then scaling up the object by 200% with the "transform gradient with object" turned on,
resulting the gradient have a double length while all the steps are in the exact location as they were before.
But that may be more complicated then simply adjusting the steps manually on screen with the handles again.
-As each offset percentage is stored like

Code: Select all

offset="0.11812243"
-

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: 2 problems with gradient

Postby v1nce » Thu Jul 04, 2013 9:18 am

yes I think I could rescale the stops by 0.909... in the base (linear) gradient then modify the gradientTransform matrix in the radialGradient that is specifically applied onto the object but I hoped there's been something simpler in the UI.

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

Re: 2 problems with gradient

Postby Lazur » Thu Jul 04, 2013 9:24 am

Just tried the method I suggested and I have to add that you have to define a step at the offset="1" to or it doesn't work right.
But if it's just about to add only one colour, you might as well duplicate the object and add an alpha to colour gradient to it to produce the wanted result.

Edit: attached is an example of the method, only to prove that how it is theoretically possible.
A bit forced though, somehow at first when the original gradient's start and end steps
weren't at an even coordinates, the scaling of the gradient wasn't performed accurately.
Attachments
graad1.svg
(7.54 KiB) Downloaded 163 times


Return to “Help with using Inkscape”