Highlighted

How can I change the color of a gradient stop via code?

New Here ,
Jun 10, 2020

Copy link to clipboard

Copied

I managed to figure how to change the location using:

 

app.activeDocument.gradients[0].gradientStops[0].location = 50;

 

but I'm lost when it comes to changing its color.

Annotation 2020-06-10 230539.png

TOPICS
Scripting

Views

125

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How can I change the color of a gradient stop via code?

New Here ,
Jun 10, 2020

Copy link to clipboard

Copied

I managed to figure how to change the location using:

 

app.activeDocument.gradients[0].gradientStops[0].location = 50;

 

but I'm lost when it comes to changing its color.

Annotation 2020-06-10 230539.png

TOPICS
Scripting

Views

126

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 10, 2020 0
Adobe Community Professional ,
Jun 10, 2020

Copy link to clipboard

Copied

You access the first one through app.activeDocument.gradients[0].gradientStops[0].stopColor;

It will return either a Color or MixedInk. From there, you can change the color profile. Ie:

var firstStop = app.activeDocument.gradients[0].gradientStops[0].stopColor;
firstStop.space = ColorSpace.RGB;
firstStop.colorValue = [100, 20, 10];

Or you can assign it to a preexisting swatch, color, etc:

app.activeDocument.gradients[0].gradientStops[0].stopColor = app.activeDocument.swatches.itemByName("PredefinedSwatch");

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 10, 2020 0