CreateShadow
创建可应用于图形对象的阴影。
语法
expression.CreateShadow(settings);
expression - 表示 Api 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| settings | 必需 | ShadowSettings | 阴影属性。 |
返回值
示例
创建阴影并将其应用于文档中的形状。
// 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 doc = Api.GetDocument();
const paragraph = doc.GetElement(0);
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);
paragraph.AddDrawing(shape);
shape.SetWrappingStyle("inFront");
shape.SetHorPosition("page", 30 * 36000);
shape.SetVerPosition("page", 30 * 36000);
const shadow = Api.CreateShadow({ color: Api.RGB(0, 0, 0), transparency: 0.4, offsetX: 3, offsetY: 3 });
shape.SetShadow(shadow);