Skip to main content

CreateGradientStop

Creates a gradient stop used for different types of gradients.

Syntax

expression.CreateGradientStop(color, pos);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
colorRequiredApiColorThe color used for the gradient stop.
posRequiredPositivePercentageThe position of the gradient stop measured in 1000th of percent.

Returns

ApiGradientStop

Example

Define color points for a gradient fill and apply them to a shape in a document.

// How do I set specific colors at positions along a gradient used on a shape in a document?

// Build a two-color gradient by placing color markers at the start and end of the fill range in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let gs1 = Api.CreateGradientStop(Api.RGB(255, 213, 191), 0);
let gs2 = Api.CreateGradientStop(Api.RGB(255, 111, 61), 100000);
let fill = Api.CreateLinearGradientFill([gs1, gs2], 5400000);
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = Api.CreateShape("rect", 5930900, 395605, fill, stroke);
paragraph.AddDrawing(shape);