Skip to content

GradientStops

app.activeDocument.gradients[index].gradientStops

A collection of GradientStop objects in a specific gradient. The elements are not named; you must access them by index.


app.activeDocument.gradients[index].gradientStops.length

The number of objects in the collection.

Number; read-only.


app.activeDocument.gradients[index].gradientStops.parent

The parent of this object.

Object; read-only.


app.activeDocument.gradients[index].gradientStops.typename

The class name of the referenced object.

String; read-only.


app.activeDocument.gradients[index].gradientStops.add()

Creates a new object.

GradientStop


app.activeDocument.gradients[index].gradientStops.getByName(name)

Gets the first element in the collection with the specified name.

ParameterTypeDescription
nameStringName of element to get

GradientStop


app.activeDocument.gradients[index].gradientStops.index(itemKey)

Gets an element from the collection.

ParameterTypeDescription
itemKeyString, NumberString or number key

GradientStop


app.activeDocument.gradients[index].gradientStops.removeAll()

Deletes all objects in this collection.

Nothing.


// Adds a new gradient stop to a gradient, color of new stop is 70% gray
if (app.documents.length > 0 && app.activeDocument.gradients.length > 0) {
// Get a reference to the gradient to change
var changeGradient = app.activeDocument.gradients[0];
// Get a reference to the last gradient stop
var origCount = changeGradient.gradientStops.length;
var lastStop = changeGradient.gradientStops[origCount - 1];
// add the new gradient stop
var newStop = changeGradient.gradientStops.add();
// Set the values of the new gradient stop.
// Move the original last gradient stop a bit to the left and insert the new gradient stop at the old position
newStop.rampPoint = lastStop.rampPoint;
lastStop.rampPoint = lastStop.rampPoint - 10;
// Create a new color to apply to the newly created gradient stop
var newStopColor = new GrayColor();
newStopColor.gray = 70.0;
newStop.color = newStopColor;
}