跳到主要内容

SetFill

设置当前图形对象的填充格式属性。

继承自 ApiDrawing.SetFill。

语法​

expression.SetFill(oFill);

expression - 表示 ApiChart 类的变量。

参数​

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

返回值​

boolean

示例​

在文档中通过基础 ApiDrawing 接口为绘图对象设置纯色填充。

// The SetFill method works for any graphic object, including images and groups, not only shapes.

// Add a rectangle to a document and fill it with a solid blue-grey color.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let drawing = Api.CreateShape("rect", 3212465, 963295, Api.CreateNoFill(), stroke);
paragraph.AddDrawing(drawing);
let fill = Api.CreateSolidFill(Api.RGB(96, 125, 139));
drawing.SetFill(fill);