跳到主要内容

CreateShadow

创建可应用于图形对象的阴影。

语法​

expression.CreateShadow(settings);

expression - 表示 Api 类的变量。

参数​

名称必需/可选数据类型默认值描述
settings必需ShadowSettings阴影属性。

返回值​

ApiShadow

示例​

在演示文稿中创建阴影并将其应用于形状。

// Build an outer shadow with a color, transparency and offset, then attach it to a drawing.

// Create a shape, create the shadow via Api.CreateShadow, and apply it 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);
const shadow = Api.CreateShadow({ color: Api.RGB(0, 0, 0), transparency: 0.4, offsetX: 3, offsetY: 3 });
shape.SetShadow(shadow);