跳到主要内容

GetTransparent

返回填充的透明度。

语法​

expression.GetTransparent();

expression - 表示 ApiFill 类的变量。

参数​

此方法没有任何参数。

返回值​

number

示例​

在演示文稿的幻灯片中读取形状填充的透明度。

// Find out how transparent a shape's fill is in a presentation.

// Check the transparency that was applied to a shape's fill on a slide in a presentation.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const fill = Api.CreateSolidFill(Api.RGB(255, 200, 100));
fill.SetTransparent(0.4);
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, fill, stroke);
shape.SetPosition(608400, 1267200);
slide.AddObject(shape);

const docContent = shape.GetDocContent();
const paragraph = docContent.GetElement(0);
const appliedFill = shape.GetFill();
paragraph.AddText("Fill transparency: " + appliedFill.GetTransparent());