跳到主要内容

GetSweepAngle

返回弧线的扫描角度。

语法

expression.GetSweepAngle();

expression - 表示 ApiPathCommand 类的变量。

参数

此方法没有任何参数。

返回值

string | null

示例

分析圆弧命令参数,包括半径和角度。获取文档中圆弧的宽度半径、高度半径、起始角度和扫掠角度。

// How can I get the sweep angle using a path command in a document?

// Get the sweep angle for a path command in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let customGeometry = Api.CreateCustomGeometry();
let path = customGeometry.AddPath();
path.SetWidth(100 * 36000);
path.SetHeight(100 * 36000);
path.MoveTo(0, 50 * 36000);
path.CubicBezTo(0, 0, 50 * 36000, 0, 50 * 36000, 50 * 36000);
path.QuadBezTo(100 * 36000, 50 * 36000, 100 * 36000, 100 * 36000);
path.ArcTo(50 * 36000, 50 * 36000, 0, 10800000);
path.Close();
let cmd = path.GetCommand(3); // arc command
paragraph.AddText("Arc: WR=" + cmd.GetWR() + ", HR=" + cmd.GetHR());
paragraph.AddText(", Start=" + cmd.GetStartAngle() + ", Sweep=" + cmd.GetSweepAngle());
let fill = Api.CreateSolidFill(Api.RGB(255, 200, 100));
let stroke = Api.CreateStroke(36000, Api.CreateSolidFill(Api.RGB(200, 100, 0)));
let shape = Api.CreateShape("rect", 80 * 36000, 80 * 36000, fill, stroke);
shape.SetGeometry(customGeometry);
paragraph.AddDrawing(shape);