跳到主要内容

SetBackground

设置当前演示文稿幻灯片的背景。

语法

expression.SetBackground(oApiFill);

expression - 表示 ApiSlide 类的变量。

参数

名称必需/可选数据类型默认值描述
oApiFill必需ApiFill用于填充演示文稿幻灯片背景的颜色或图案。

返回值

boolean

示例

此示例设置幻灯片的背景颜色。

// How to change a background color of the slide.

// Get a slide by its index, set its background and add it to the presentation.

const presentation = Api.GetPresentation();
const slide = Api.CreateSlide();
const gs1 = Api.CreateGradientStop(Api.RGB(255, 213, 191), 0);
const gs2 = Api.CreateGradientStop(Api.RGB(255, 111, 61), 100000);
const fill = Api.CreateRadialGradientFill([gs1, gs2]);
slide.SetBackground(fill);
presentation.AddSlide(slide);