跳到主要内容

SetShadow

为当前图形对象设置阴影。

继承自 ApiDrawing.SetShadow。

语法​

expression.SetShadow(shadow);

expression - 表示 ApiSmartArt 类的变量。

参数​

名称必需/可选数据类型默认值描述
shadow必需ApiShadow | null | undefined要应用的阴影,或传递 null 以移除当前阴影。

返回值​

boolean

示例​

在演示文稿中为绘图对象应用外部阴影。

// Give a shape a soft offset shadow so it appears lifted off the slide.

// Create a shape, build a shadow, and set it on the drawing with SetShadow.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();
const fill = Api.CreateSolidFill(Api.RGB(255, 213, 191));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape("rect", 120 * 36000, 60 * 36000, fill, stroke);
shape.SetPosition(40 * 36000, 40 * 36000);
slide.AddObject(shape);
shape.SetShadow(Api.CreateShadow({ color: Api.RGB(64, 64, 64), transparency: 0.3, offsetX: 4, offsetY: 4 }));