SetFill
设置当前形状的填充属性。
语法
expression.SetFill(oFill);
expression - 表示 ApiShape 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| oFill | 必需 | ApiFill | 用于填充形状的填充类型。 |
返回值
boolean
示例
为形状设置纯色填充。
// Creates a rectangle and applies a red fill to it.
let presentation = Api.GetPresentation();
let slide = presentation.GetSlideByIndex(0);
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = Api.CreateShape("rect", 100 * 36000, 50 * 36000, Api.CreateNoFill(), stroke);
shape.SetPosition(2000000, 1000000);
slide.AddObject(shape);
let content = shape.GetDocContent();
let paragraph = content.GetElement(0);
paragraph.AddText("Original shape with no fill");
let fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 0, 0));
shape.SetFill(fill);
paragraph.AddLineBreak();
paragraph.AddText("Fill changed to red");