CreatePatternFill
创建图案填充,使用所选图案作为对象背景应用于对象。
语法
expression.CreatePatternFill(patternType, bgColor, fgColor);
expression - 表示 Api 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| patternType | 必需 | PatternType | 从可用图案类型中选择的用于填充的图案类型。 | |
| bgColor | 必需 | ApiColor | 用于创建图案的背景色。 | |
| fgColor | 必需 | ApiColor | 用于创建图案的前景色。 |
返回值
示例
此示例创建图案填充,并使用所选图案作为对象背景应用于对象。
// How to apply pattern to the background of a drawing.
// Change color of an element using a pattern fill.
const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();
const fill = Api.CreatePatternFill("dashDnDiag", Api.RGB(255, 111, 61), Api.RGB(51, 51, 51));
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);