跳到主要内容

CreateLinearGradientFill

创建线性渐变填充,使用所选线性渐变作为对象背景应用于对象。

语法

expression.CreateLinearGradientFill(gradientStops, angle);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
gradientStops必需number[]以千分之一百分比度量的渐变颜色光圈数组。
angle必需PositiveFixedAngle以六万分之一度度量的角度,用于定义渐变方向。

返回值

ApiFill

示例

此示例创建线性渐变填充,使用选定的线性渐变作为对象背景应用于对象。

// How to create a linear gradient fill to set it as a drawing background.

// Change a drawing background using gradient fill.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const gs1 = Api.CreateGradientStop(Api.RGB(255, 213, 191), 0);
const gs2 = Api.CreateGradientStop(Api.RGB(255, 111, 61), 100000);
const fill = Api.CreateLinearGradientFill([gs1, gs2], 5400000);
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const drawing = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, fill, stroke);
drawing.SetPosition(608400, 1267200);
slide.AddObject(drawing);