Skip to main content
Inspiring
February 23, 2020
Answered

changeFillGradients option for .resize() method on a PathItem seems to do nothing?

  • February 23, 2020
  • 3 replies
  • 1727 views

I'm playing around with the .resize() method in an Illustrator script and the "changeFillGradients" option seems not to do anything.

 

For reference: https://illustrator-scripting-guide.readthedocs.io/jsobjref/PathItem/#pathitem-resize

 

I'm expecting the gradient fill of the object to scale or remain the same based on my input but it just scales with the object whether or not the changeFillGradients option is true or false. For example:

 

This code:

 

 

object.resize(
	200, 
	200,
	true, //changePositions,
	true, //changeFillPatterns,
	true, //changeFillGradients,
	true, //changeStrokePattern,
	true //changeLineWidths,
)

 

 

 

Acts exactly the same as:

 

 

object.resize(
	200, 
	200,
	true, //changePositions,
	true, //changeFillPatterns,
	false, //changeFillGradients,
	true, //changeStrokePattern,
	true //changeLineWidths,
)

 

 

 

Everything else behaves as expected. The object scales, pattern fills scale, line widths scale, but gradient fills don't. Anybody have any idea what's going on here?

 

EDIT: This same issue seems to be present for the .translate() method. Maybe I'm just missing how this option is supposed to be used for the .translate() and resize() methods. It works just how I expect it to on the .rotate() method...

This topic has been closed for replies.
Correct answer renél80416020

Salut!

Voilà un cas où on voit la différence.

 

3 replies

m1b
Community Expert
Community Expert
May 9, 2020

I've found the exact same problem: the transformation methods on pathItem don't seem to transform gradients.

Here's an example with two boxes with radial gradient fills:

// move the item and gradient (works)
app.activeDocument.pageItems[0].translate(
    20, 0, true, true, true, true, true);

// don't move the shape, just the gradient (doesn't work)
app.activeDocument.pageItems[1].translate(
    20, 0, false, true, true, true, true);

 

As a related issue, setting the gradient.origin or angle via script had no effect for me either.

I'm running Illustrator 24.1.2 Mac OS Catalina 10.15.4 (19E287).

P.S. Maybe the "correct answer" was marked accidentally?

renél80416020
Inspiring
May 9, 2020

Bonjour Mark!

Tu devrais réfléchir un peu...

Pouquois ça changerait dans ton exemple?

René

 

m1b
Community Expert
Community Expert
May 9, 2020

Thanks for your prompt reply René! I expected this result:

 

I expected that the second call to translate would move the gradient fill, but not the path itself.

Do you know the way to do that via scripting? I have also tried moving the shape and *not* the gradient but that moves the gradient also. I cannot achieve the above result via script. I know I must be missing something!

renél80416020
renél80416020Correct answer
Inspiring
March 7, 2020

Salut!

Voilà un cas où on voit la différence.

 

Disposition_Dev
Community Expert
Community Expert
February 24, 2020

can you share some screenshots? I'm not really understanding how the gradient is supposed to scale.

Inspiring
February 26, 2020

I'd imagine it scales by moving the endpoints of the gradient inward or outward relative to the object, but I'm not sure since I've never been able to get the changeFillGradients argument to do anything. Moving the gradient would seem to be straightforward as well, since I'm moving it in the attached screenshot.