跳到主要内容

SetFill

设置当前形状的填充属性。

语法

expression.SetFill(oFill);

expression - 表示 ApiShape 类的变量。

参数

名称必需/可选数据类型默认值描述
oFill必需ApiFill用于填充形状的填充类型。

返回值

boolean

示例

为形状设置纯色填充颜色。在文档中创建矩形并为其应用红色填充。

// How to set fill for a shape in a document?

// Set fill and display the result in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = Api.CreateShape("rect", 100 * 36000, 50 * 36000, Api.CreateNoFill(), stroke);
paragraph.AddDrawing(shape);
paragraph.AddLineBreak();
paragraph.AddText("Original shape with no fill");
paragraph.AddLineBreak();
let fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 0, 0));
shape.SetFill(fill);
paragraph.AddText("Fill changed to red");